Hi ,
I have two entities where entities 1 having currency field, and entity 2 having total amount
so, when i have 5 records with different amounts in that and I need to get the total sum of all record currency in entity 2 field called total amount, please help me on this how i can get using flows.
entity 1
currency 100
currency 200
currency 300
currency 100
currency 20
entity 2
total amount 720
As an example, I've created the below Dataverse Table with the default Name column and another column called Currency of type number (decimal). The internal name for my Currency column is cra85_currency.
Below is my full flow that will get the sum of all the numbers. I'll go into each of the actions.
List rows retrieves all the data in my Dataverse Table.
We then use a Compose action (I've called it XML) to convert the JSON (body) from List rows to XML so we can use XPath to sum the numbers. This means we don't need to have a loop which makes it much more efficient/cleaner. The expression I use here is below. Effectively it's wrapping the output of List rows into a root element (required for valid XML), then converting to json then xml.
xml(json(concat('{"root": ', outputs('List_rows')?['body'], '}')))
Total is a Compose action that uses an XPath expression to sum all the numbers. The expression is below. Note that I've used my internal Currency name cra85_currency. You would need to put the internal name of your column here.
xpath(outputs('XML'), 'sum(//value/cra85_currency/text())')
And that's it. The output of Total is below:
You can then add the total to your other Table.
Hi Grantjenkins,
I have created list rows for the output and need to get total sum to another field in different entity,
I am using the list rows to of both separately.
Trying as below
Are you able to show the JSON output from your Dataverse table (assuming you're using List rows action)? Specifically, the internal name of your Currency field.
Yes it is dataverse used to create entity .
WarrenBelz
146,535
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,908
Most Valuable Professional