Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
jvargasmayorga
Contributor III
Contributor III

sum values of last months

Hello Community.
I have the following problem.
This is a sum of quantities table, grouped by time dimension (Year and Month)

Cant. Trx

 

Sum(Cantidad_transito)

 

 

jvargasmayorga_0-1657313106603.png

 

What I need now is to add the values of the last 3 months, but for each month.
For June: You must add the values of April, May and June
For February: You must add the values December 2021, January and February. Something like that:

jvargasmayorga_1-1657313132552.png

 

In this sum I am having problems. I use the following formula and it gives me the wrong result (same as a simple sum)
Qty trx 3 Month =>

 

sum({<Fecha_transito={">=$(=MonthStart(AddMonths(Max(Fecha_transito),-2)))<=$(=MonthEnd(AddMonths(Max(Fecha_transito),0)))"}>} Cantidad_transito)

 

 

jvargasmayorga_2-1657313209217.png

 

Using this formula (adding  TOTAL), it only considers the sum of the last 3 months and that result places it in all the same months.

 

 

sum({<Fecha_transito={">=$(=MonthStart(AddMonths(Max(Fecha_transito),-2)))<=$(=MonthEnd(AddMonths(Max(Fecha_transito),0)))"}>} TOTAL Cantidad_transito)

 

 

jvargasmayorga_3-1657313228060.png

 

I think the solution would be like NOT considering the time dimension in the sum, but showing it each in its own time, it's very confusing, any idea how to solve it? Need this result.

jvargasmayorga_4-1657313261216.png

 

Thanks

Labels (2)
10 Replies
jvargasmayorga
Contributor III
Contributor III
Author

hello.
I did what you indicated and it seems to be ready, when I do the validation there are few records that do not match. I will review the data now, to confirm if it is ok. But you helped me a lot.
Thank you