How to Sum Column in Power Apps Data Table?

Recently, I got a requirement to work with the Power Apps data table sum column, and we can achieve it by using the Power Apps Sum() function.

In this Power Apps tutorial, I will show you how to sum column in Power Apps Data table control.

How to Sum Column in Power Apps Data Table

Let’s take a simple scenario.

I have a SharePoint Online list named “Expense Tracker” and this list contains the below fields.

Input:

Column NameData Type
ItemIt is a default single line of text colum
Expense TypeChoice
BudgetChoice
MonthChoice
AmountCurrency
Power Apps Data Table Sum Column

I want to display these list records on the Power Apps data table control, calculate the total amount [From the “Amount” column], and display the result on the text label control.

Have a look at the below screenshot for the output:

Output:

How to calculate sum of the Power Apps data table column

To work around this, follow the below-mentioned steps. Such as:

1. Open Power Apps with your respective Microsoft credentials -> Create a Blank Canvas app and connect it to the specific SharePoint Online list [Expense Tracker] like below.

Sum data table column in Power Apps

2. On the Power Apps Screen -> Insert a Data table control and set its Items property to the code below.

Items = 'Expense Tracker'

Where,

  • ‘Expense Tracker’ = SharePoint Online List
How to sum data table column in Power Apps

3. Insert a Text label and set its Text property to the code below.

Text = "Total Sum of Amount: " & Sum(DataTable_Records, 'Amount')

Where,

  • Sum() = Power Apps Sum() function helps to calculate the sum of its arguments
  • DataTable_Records = Power Apps Data table name
  • ‘Amount’ = SharePoint list currency field
See also  Power Apps Modern Table Control [How to Use]

4. Whenever I use this function, unfortunately, it will give an error like [“The function ‘Sum’ has some invalid arguments“]. Also, remember that there is no direct way to calculate the sum in the PowerApps Data table.

Sum of a column from Power Apps data table

To resolve this issue, two ways exist to work with the Power Apps Data table sum column. Such as:

  • Power Apps Data Table Sum Column using SharePoint List
  • Power Apps Data Table Sum Column using Gallery control

Power Apps Data Table Sum Column using SharePoint List

1. Now, I will show you how to calculate the total sum of the Power Apps data table column using a SharePoint list. To do so, select the Text label and set its Text property as:

Text = "Total sum of Amount:  " & Sum('Expense Tracker',Amount)

Where,

  • ‘Expense Tracker’ = SharePoint Online list

Now, we will get the total sum of the amount in the text label with a Delegation warning [Yellow Trangle] like “Delegation warning. The highlighted part of this formula might not work correctly on large data sets. This connector does not support the “Sum” operation.”

Power Apps sum data table column

2. To resolve this delegation warning, we can create the collection using a respective SharePoint Online list and add this collection to the sum function. For that, select the App object [From the left navigation] and set its OnStart property.

OnStart = ClearCollect(colExpenses,'Expense Tracker')

Where,

  • colExpenses = Power Apps collection name
  • ‘Expense Tracker’ = SharePoint list
Power Apps Data Table Sum Column using a SharePoint List

3. Next, select the Text label and set its Text property.

Text = "Total Sum of Amount: " & Sum(colExpenses,Amount)

Where,

  • colExpenses = Power Apps collection name
Power Apps Data Table Sum Column using SharePoint List

4. Once your app is ready, Save, Publish, and Preview the app. The Power Apps text table displays the total sum of the amount without any delegation warning, as in the screenshot below.

Power Apps Data Table Sum Column using the SharePoint List

This way, you can calculate the sum of the Power Apps data table column.

See also  How to Hide a Column in Power Apps Data Table?

Power Apps Data Table Sum Column using Gallery control

To calculate the sum of a Power Apps data table column, the best approach is to use a Blank gallery control instead of using a Data table, and it will work as a data table. Have a look at the below screenshot for the output.

Output:

How to calculate sum of Power Apps data table column

To achieve it, follow the below steps.

1. On the Power Apps Screen -> Insert a Blank vertical gallery control and set its Item property as:

Items = 'Expense Tracker'
Calculate sum of Power Apps data table column

2. Select the edit icon inside the gallery and add respective text labels to display the SharePoint list records. Whenever you add the Text label, it will give a specific list record with the default Text property.

Text = ThisItem.Title

Text = ThisItem.'Expense Type'.Value

Text = ThisItem.Budget.Value

Text = ThisItem.Month.Value

Text = ThisItem.Amount

Text = ThisItem.'Payment Date'

Where,

  • Title, ‘Expense Type’, Budget, etc… = SharePoint list fields
Calculate sum of the Power Apps data table column

3. Add a Text label under the Gallery control and set its Text property to the code below.

Text = "Total Sum of Amount: " & Sum(gal_Records.AllItems,Amount)

Where,

  • gal_Records = Power Apps gallery control name
Power Apps Data Table Sum Column using Gallery control

4. Save, Publish, and Preview the app. The text label will display the total sum of the amount, as in the screenshot below.

Calculate sum of data table column in Power Apps

Conclusion

I trust this Power Apps tutorial taught in detail information about the Power Apps Data table sum column using diffrent ways.

Additionally, you may like some more Power Apps articles:

>