cumulative column in a DataGrid

0
Hi Im looking for a solution how to make a column in a DataGrid cumulative. In that column each rows value has to be added to the row above and show that value.  I tried to make the value with a microflow in the domainmodel but ……. it doesnt work the way i want it to.     
asked
3 answers
2

I would suggest creating a microflow as the data source for your grid. In this microflow you retrieve the Invoices that you want to display.

Then you sort them in the order you want them (if needed).

Then you create a variable 'cumulative’. Set it to 0.

Then in a loop where you loop over the Invoices you change the variable 'cumulative’ to '$cumulative + the total from the invoice’.

Then you change the 'RunningTotal' in the IteratorInvoice to ’$cumulative'.

Now the every Invoice has a running total with the totals of the previous Invoices combined + its own total.

Do note that this does not work if you plan to put filters on the grid or if the user can change the sort direction of the columns.

answered
0

You need to know exactly which value is in each row in order to make it work properly. This means you need to update these values any time a row gets inserted or removed.

The easiest solution I can think of is to use a datasource microflow to get the list of invoices to display. Make sure you use sorting to have the list always behave the same. Create a variable for the cumulative total, start value 0. Loop over the list and for each object add the value to the variable and set the value of the last column to the value of the variable.

This should do the trick.

 

-edit- Exactly the same as Martin posted a few seconds earlier :) In addition to the filtering/sorting Martin points out: you could solve that with microflows as well, but that's going to be a lot of custom work. You need to consider if it's worth it or not.

answered
0

Thanks! 

It works like a charm

 

 

answered