Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
OcCook
Contributor II
Contributor II

Help with Calculating 90-Day Rolling Accumulated Orders in Qlik

Hola, necesito ayuda para configurar una tabla en Qlik que muestre un acumulado de pedidos en una ventana móvil de 90 días. Tengo una columna con las fechas y otra con la cantidad de pedidos diarios, y quiero que, para cada día, se calcule el total de pedidos de los últimos 90 días, incluyendo el propio día actual.

Por ejemplo, si el primer día seleccionado tiene 5 pedidos, en la columna de acumulado debería aparecer los 5 + los últimos 90 días desde esa fecha, en el segundo día, el acumulado debería sumar los pedidos del segundo día + los últimos 90 días , y así sucesivamente. Básicamente, quiero que, para cada fecha en la tabla, se incluya el total de pedidos de los últimos 90 días anteriores hasta ese día.

-------------------------------------------------------------------------------------------------------------------------------------------------------

 

Hi, I need help setting up a table in Qlik that shows an accumulated total of orders in a rolling 90-day window. I have one column with dates and another with the daily order count, and I want the table to calculate the total orders for the last 90 days, including the current day, for each date.

For example, if the first selected day has 5 orders, the accumulated column should show those 5 orders plus the total of the previous 90 days from that date. On the second day, the accumulated total should sum the orders of the second day plus the last 90 days, and so on. Essentially, I want each date in the table to display the total orders from the previous 90 days up to that specific day.

Labels (6)
1 Solution

Accepted Solutions
Qrishna
Master
Master

The calculation of rolling Sum gets tricky in the load script and more trickier on the UI especially when you you want to exclude the dim selections while calculating the summation for dims values tht includes the excluded dim selections, as Rangesum(above(..)) calculates thats available within the set/chart, when you exclude some dates, the chart also excludes those rows.

We usually do in the script by creating As-Of-Table 

This is not really the efficient way if you have millions of rows and want to calculate sum of previous 90 days for each date. rather i would suggest doing last 3months and not 90 days i.e converting days to months in the script, as the As of table is a cartesian product table that creates uncountable records for dates. but you can  do something like below:

data:
LOAD Date, *
from Your_table;

[Date Linkage]:
LOAD Date as AsOfDate
Resident data
;
LEFT JOIN ([Date Linkage])
LOAD Date,
'LastX' as DateType
Resident data
;
INNER JOIN ([Date Linkage])
LOAD *
Resident [Date Linkage]
WHERE Date <= AsOfDate AND
Date >= AsOfDate - 90;

 

On the UI, in the st table:

Dim: AsOfDate

measure: sum({<DateType={'LastX'}>} OrderCount)

2492763 - Accumulation of 90 Dyas Count (2).PNG

 

2492763 - Accumulation of 90 Dyas Count (3).PNG

 

View solution in original post

4 Replies
Qrishna
Master
Master

=Num(Rangesum(Above(sum(OrderCount),0,90)))

 

2492763 - Accumulation of 90 Dyas Count .PNG

OcCook
Contributor II
Contributor II
Author

Muchas gracias por la respuesta funciona, pero lo que necesito es acumular los 90 días seleccionados desde la primera selección, imagina que tengo 180 días de pedidos, y tengo seleccionado la mitad hacia adelante, desde esa mitad necesito acumular los pedidos hacia atrás y sumarlos para las fechas siguiente, dejo imagen de referencia lo que esta en verde es la selección por si no se entendió bien.

-----------------------------------------------------------------------------------------------------------------------------------------------

Thank you very much for the response; it works, but what I need is to accumulate the selected 90 days starting from the first selection. Imagine I have 180 days of orders, and I have selected the second half moving forward. From that midpoint, I need to accumulate the orders backward and sum them for the following dates. I'm leaving a reference image; the green section represents the selection in case it wasn’t clear.

OcCook_1-1731595126055.png

 

 

 

Qrishna
Master
Master

The calculation of rolling Sum gets tricky in the load script and more trickier on the UI especially when you you want to exclude the dim selections while calculating the summation for dims values tht includes the excluded dim selections, as Rangesum(above(..)) calculates thats available within the set/chart, when you exclude some dates, the chart also excludes those rows.

We usually do in the script by creating As-Of-Table 

This is not really the efficient way if you have millions of rows and want to calculate sum of previous 90 days for each date. rather i would suggest doing last 3months and not 90 days i.e converting days to months in the script, as the As of table is a cartesian product table that creates uncountable records for dates. but you can  do something like below:

data:
LOAD Date, *
from Your_table;

[Date Linkage]:
LOAD Date as AsOfDate
Resident data
;
LEFT JOIN ([Date Linkage])
LOAD Date,
'LastX' as DateType
Resident data
;
INNER JOIN ([Date Linkage])
LOAD *
Resident [Date Linkage]
WHERE Date <= AsOfDate AND
Date >= AsOfDate - 90;

 

On the UI, in the st table:

Dim: AsOfDate

measure: sum({<DateType={'LastX'}>} OrderCount)

2492763 - Accumulation of 90 Dyas Count (2).PNG

 

2492763 - Accumulation of 90 Dyas Count (3).PNG

 

OcCook
Contributor II
Contributor II
Author

Muchas Gracias!!!!!