Hi All,
Can I get SUM from calculated attribute on aggreagate,
Regards,
Kane
Yes, you just need to click on the column that you want to do the sum and it will present you the sum option. Have a look at this post, talking about "How to auto-calculate the total price from two different aggregates in a web screen "
https://www.outsystems.com/forums/discussion/68037/how-to-auto-calculate-the-total-price-from-two-diferent-aggregates-in-a-web-scree/
And then it will be presented to you the output to be used
Márcio
Hi,
I don't think this is the right answer to my problem. But your answer can still be reproduced with my problem now
I have tried to add new attribute and do a calculated from groupped attribute.
Next I do loop and assign calculated to variable (Calculated attribute + variable)
to get the SUM result of groupped attribute.
Thanks
Have a look at @Matthias Preuter 's answer :)
Hi Kane,
Yes, you can, if the field is a numeric one, of course. Like on the image below, after right-clicking the calculated field:
Kind Regards,João
Yes, this SUM function can be use in calculated aggregate, but how to SUM on already grouped attributes,
Thanks,
Do you mean a grand total of the grouped attributes? Think the most simple way is to Loop thru the Aggregate-result and sum the Attributes.
On aggregate already groupped attributes like this:
NAME | TYPE | Total Early | Total End |
Kane |R |1000 |0
Kane |L |0 |2000
John |R |1000 |0
How can I sum TOTAL EARLY and TOTAL END on same NAME like this:
NAME | TOTAL EARLY | TOTAL END
Kane |1000 |2000
John |1000 |0
Because if I SUM TOTAL EARLY and TOTAL END will SUM all NAME
Do you want a grouped sum on Name and Name and Type?
I want to SUM TOTAL EARLY and TOTAL END with groupped NAME.
But NAME already SUM
Ok, if I understand correctly you want a subtotal on Name like this:
Exactly
Clear, this isn't possible by only using a Aggregate; you have to post-process the data from the aggregate to add the SubTotals. There are more ways to do that, but a way to do it, is by inserting a Subtotal record when the Name changes, like this:
- First query your dataset
- Duplicate the List; because we want to insert a record in the result dataset, we need to iterate through another list
- initialize the first subtotal record (Name and Totals set to 0)
- Loop through the Duplicate list add the values to the Sum in the Subtotal record
- when Name is change insert the Subtotal record in the original list, and initialize the subtotal record again
- finally append the last Subtotal record to the original list, and return the original list as output
Hope this helps,
Matthias
Appreciate for your answer, but I think it's difficult just looking at your image, because a flow is very complicated that I think before. Can you share your .oml so that I can understand more.
Attached a sample that gives this result:
And a sample in Traditional web...