Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
AidaAR
Contributor II
Contributor II

Aggregation not working

Hi community,

I am trying to do an aggregation of a calculated field in my app but it does not work properly. The calculated field does work as it gives a value for each item but when trying to sum it, it gives always a 0 as a result. 

The calculated field is called PERDTH TOTAL whereas the aggregation dimension is TOTAL PERD TH:

TOTAL PERD TH: SUM(AGGR([PERDTH TOTAL],[AñoMes]))

I've tried changing the aggregation field but that does not work either.

If you have any idea as to why it does not work please help me. I thought I understood the aggregation function... 😞

Labels (4)
6 Replies
TauseefKhan
Creator III
Creator III

Hi @AidaAR,

Check this:
Sum(Aggr(Sum([PERDTH TOTAL]), [AñoMes]))

gomeri
Partner - Contributor III
Partner - Contributor III

HI @AidaAR, formula given by @TauseefKhan is working.

If you create a Table where in first column you have dimension "PERDTH TOTAL" and in second column measure "=SUM(Aggr(SUM([PERDTH TOTAL]), AñoMes))" the result will be follow (i my case i change dimension "PERDTH TOTAL" in "VALORE" and "AñoMes" in "DATA":

gomeri_0-1718698127940.png

gomeri_1-1718698150720.png

gomeri_2-1718698226802.png

 

Let us know if it's working

Thanks

 

Giovanni O. D.
AidaAR
Contributor II
Contributor II
Author

Hi, no still not working. The first table in the image is the calculation of the PERDTH TOTAL by item and as you can see it gives a value per each item. The second is the aggregation of that value and it gives 0...

 

AidaAR_0-1718710384881.png

 

the formulation of the field PERDTH TOTAL is:

AidaAR_2-1718710443396.png

PERDTH TOTAL=NUM(COALESCE(0.01*[RMTO PESO LC]+ [RMTO PERDTH CONO]+[RMTO PERDTH CARRETE]+[RMTO PERDTH COLAS]+IF([RMTO REBORDEO]='S',7.85*[RMTO ESP RF]*[INS. Largo Minimo]/1000*([PRO Ancho anterior]-[RMTO ANCHO RF]),0),0),'0,00')

 

And the aggregation I put it as you said:

TOTAL PERD TH MES=Sum(Aggr(Sum([PERDTH TOTAL]), [AñoMes]))

 

 

gomeri
Partner - Contributor III
Partner - Contributor III

To solve this problem, you need to create a new variable or in "Editor Script" or in "Variables" of Sheet Editor.

In first case, you need to go into "Data Load Editor" and create:

- a new variable named "PERDTH TOTAL":

Let PERDTH TOTAL=NUM(COALESCE(0.01*[RMTO PESO LC]+ [RMTO PERDTH CONO]+[RMTO PERDTH CARRETE]+[RMTO PERDTH COLAS]+IF([RMTO REBORDEO]='S',7.85*[RMTO ESP RF]*[INS. Largo Minimo]/1000*([PRO Ancho anterior]-[RMTO ANCHO RF]),0),0),'0,00')

gomeri_0-1718715143111.png

 

In second case, you need to go into from sheet to Variables and create new variable called "PERDTH TOTAL" with same definition. 

gomeri_1-1718715193959.png

 

once the variable has been created, it is possible to insert the newly created variable within the second expression

 

Sum(Aggr(Sum($(PERDTH TOTAL)), [AñoMes]))

 

Giovanni O. D.
AidaAR
Contributor II
Contributor II
Author

Good morning,

Still not working... Might it be because the calculation of PERDTH TOTAL is done with data from different tables? It shouldn't  be a problem but I don't know what else could be...

 

gomeri
Partner - Contributor III
Partner - Contributor III

Good morning, 

I wouldn't know how else to help you. I would advise you at this point to check the data model and see if it is possible to pre-calculate within the logical data model.

In case you manage to solve the problem yourself, let me know how you did it.

Thanks

Giovanni O. D.