I have a gallery
control in power app with months column from Jan
to Dec
. Each column will have input text control of Number
type. The controls are editable. I have added a row before header with Label
control in scrollable container to show the total of each column from Jan
to Dec
. I want it to get displayed on the run as user edit any Input text of any column, it should display SUM()
of each column in above Label
.
The logic that I have used is having some syntax error. Unable to find error:
Text(
Sum(
ForAll(
Gallery1_1.AllItems, Value(TextInputJan_1.Text)
)
)
)
The error I am getting under ForAll
condition is Expected number. We expect a number at this point in the formula.
The Sum function has two "overloads": you can either pass to it a list of numbers, to get their sum:
Sum(1, 2, 3, 4) // Will return 10
Or you can pass a table to it, and an expression to be evaluated for every item of the table:
Sum([{a:1}, {a:3}, {a:5}], a) // Will return 9
In your scenario, the argument to the Sum function is the result of the ForAll function, which is a table; this is not a supported way to call that function today.
To solve that, you can remove the ForAll call: Gallery1_1.AllItems is a table where one of its properties is TextInputJan_1, so you can use it directly:
Text(
Sum(
Gallery1.AllItems,
Value(TextInputJan_1.Text)
)
)