cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AmateurCMDR
Level: Powered On

Possible to use aggregate transformation to sum filtered CDS field values?

Within a flow, I am using the 'List Records' action. I have successfully applied an OData filter that only lists records with the appropriate project value. Is it possible to also apply an aggregate transformation to sum the numeric values of a field in the filtered items.

1 REPLY 1
Community Support Team
Community Support Team

Re: Possible to use aggregate transformation to sum filtered CDS field values?

Yes, it is possible.

Within PowerApps, there is a Sum () function available to sum the special field within a table.

Sum( Table, NumericalFormula )

For example:

"

Sum(Sales, CostPerUnit * UnitsSold)

The label would show total sales by multiplying the values in those columns for each record and then adding the results from all records together:
Calculate total sales from units sold and cost per unit

"

Function reference.

 

If you would like to do it within Microsoft Flow, you need to take use of Variable and an Apply to each to sum the numeric field value within a table.

If here you prefer Microsoft Flow, then please try the steps below:

1. After the Get Items action, add two Variables, name them with SumField, another with Total,

2. Add an Apply to each, enter the Value of the Get Items action,

3. within Apply to each, add two Set Variable action, 

4. For the first Set Variable action, select SumField, with the value enter the following expression:

add(variables('Total'), items('Apply_to_each')?['ID'])

Here I take use of the SharePoint Get Items action ID field as an example.

5. with the second Set Variable action, select Total Value, enter the value field with:

Variable SumField.

6. Outside Apply to each, take use of the compose to check the Total Variable value.

Image reference:

141.PNG142.PNG

 

Best regards,

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.