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 Name | Data Type |
Item | It is a default single line of text colum |
Expense Type | Choice |
Budget | Choice |
Month | Choice |
Amount | Currency |
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:
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.
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
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
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.
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.”
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
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
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.
This way, you can calculate the sum of the Power Apps data table column.
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:
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'
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
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
4. Save, Publish, and Preview the app. The text label will display the total sum of the amount, as in the screenshot below.
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:
- Filter Power Apps Data Table By Dropdown
- Change Date Format in Power Apps Data Table
- Set Alternate Row Color in Power Apps Data Table
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com