156
Views
7
Comments
Solved
Using the same aggregate for two different purposes on the same screen
Application Type
Reactive

Hello, I need your help.

I have an entity called 'FruitSales'. For table 1, I simply fetched this entity and an aggregate 'GetFruitSales' was created to display all the data.

Can I use the same aggregate to create table 2 as shown above on the same screen? If not then, how can I implement this? I'm new to outsystems development so any help would be appreciated.

Thanks in advance!

2023-03-16 16-29-51
Paulo Rosário
Solution

Hello Shreya , 

I'm afraid that you will not be able to use the same aggregate for both tables because in the second table you and to show the Sum of values and this creates a different output.

You can however use a copy of that aggregate (let's call it "GetSumOfFruitSales"  ) and add the filters that you need by using the SUM option on the new aggregate on all 3 types of fruit and the group by option in the Year column.  

And this should be the result : 

Hope it helps!

Paulo Rosário

UserImage.jpg
Shreya Sahay

Hi Paulo, 

Thank you so much for providing this solution. Would it be possible for you to share this OML? It would be really helpful to understand how to bind the dropdown to the second table. I am sorry if this seems like a silly thing but I am new to all of this so I need some extra help at this stage.

UserImage.jpg
Shreya Sahay

I followed your solution and was able to fetch the sum values using a copy of the first aggregate. However, I am not able to implement the dropdown by binding it to the year. Could you please help?

2023-03-16 16-29-51
Paulo Rosário

Hello Shreya,

I will attach the oml so you can take a look :) 

Hope it helps! 

Paulo Rosário

Sum and Group By.oml
UserImage.jpg
Shreya Sahay

Thank you a lot, Paulo, for your support!!

2024-03-22 09-17-23
Chandra Vikas Sharma

Hi Shreya,

You can use two aggregate in one screen for showing to different data show.

2020-02-28 09-46-54
Eduardo Jauch

Hi Shreya

Chandra already mentioned you can have multiple aggregates and data actions on a screen.

Let me just complement by saying that while it is "possible" to use the same aggregate to provide data for multiple widgets, this is usually not advisable, and in your case, specifically, that is not possible at all, as you are showing the data in very different ways.

An Aggregate is just an element that helps you create queries in a visual way, but it still follows SQL rules. 
Your first table shows the data aggregated by month and year, while the second only by year. 
A single aggregate will not be able to fetch both at the same time. Using an SQL Tool it would be possible, but as it would be tricky, if you don't have performance problems, you are starting in OutSystems, and for other reasons, I don't recommend.

So, just use 1 aggregate to fetch the data for the first table, and a second one for the second table.

Cheers!


2023-03-16 16-29-51
Paulo Rosário
Solution

Hello Shreya , 

I'm afraid that you will not be able to use the same aggregate for both tables because in the second table you and to show the Sum of values and this creates a different output.

You can however use a copy of that aggregate (let's call it "GetSumOfFruitSales"  ) and add the filters that you need by using the SUM option on the new aggregate on all 3 types of fruit and the group by option in the Year column.  

And this should be the result : 

Hope it helps!

Paulo Rosário

UserImage.jpg
Shreya Sahay

Hi Paulo, 

Thank you so much for providing this solution. Would it be possible for you to share this OML? It would be really helpful to understand how to bind the dropdown to the second table. I am sorry if this seems like a silly thing but I am new to all of this so I need some extra help at this stage.

UserImage.jpg
Shreya Sahay

I followed your solution and was able to fetch the sum values using a copy of the first aggregate. However, I am not able to implement the dropdown by binding it to the year. Could you please help?

2023-03-16 16-29-51
Paulo Rosário

Hello Shreya,

I will attach the oml so you can take a look :) 

Hope it helps! 

Paulo Rosário

Sum and Group By.oml
UserImage.jpg
Shreya Sahay

Thank you a lot, Paulo, for your support!!

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