1113
Views
16
Comments
SUM calculated attribute on aggregate
Application Type
Traditional Web

Hi All,

Can I get SUM from calculated attribute on aggreagate,


Regards,

Kane

2021-06-02 20-50-04
Márcio Carvalho

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

Regards,

Márcio

2020-11-13 06-20-57
Kane Loony

Hi,

I don't think this is the right answer to my problem. But your answer can still be reproduced with my problem now

Regards,

Kane

2020-11-13 06-20-57
Kane Loony

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

2021-06-02 20-50-04
Márcio Carvalho
2018-10-29 08-31-03
João Marques
 
MVP

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

2020-11-13 06-20-57
Kane Loony

Hi,

Yes, this SUM function can be use in calculated aggregate, but how to SUM on already grouped attributes,


Thanks,

Kane

2024-12-17 14-32-59
Matthias Preuter
 
MVP

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.

2020-11-13 06-20-57
Kane Loony

Hi,

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


Regards,

Kane

2024-12-17 14-32-59
Matthias Preuter
 
MVP

Do you want a grouped sum on Name and Name and Type?

2020-11-13 06-20-57
Kane Loony

I want to SUM TOTAL EARLY and TOTAL END with groupped NAME.

But NAME already SUM

2024-12-17 14-32-59
Matthias Preuter
 
MVP

Ok, if I understand correctly you want a subtotal on Name like this:

2024-12-17 14-32-59
Matthias Preuter
 
MVP

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

2020-11-13 06-20-57
Kane Loony

Hi,

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.


Regards,

Kane

2024-12-17 14-32-59
Matthias Preuter
 
MVP

Attached a sample that gives this result:


Subtotal.oml
2024-12-17 14-32-59
Matthias Preuter
 
MVP

And a sample in Traditional web...

Subtotal_TW.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.