Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Don't miss the upcoming Q&A with Qlik session on Qlik Application Automation on November 16th! REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nezuko_kamado
Contributor III
Contributor III

Sum units by IDs for every 4 weeks

How can I sum units of every 4 weeks by the IDs.

So if I click week 1, then unit of week 1~4 get summed by IDs

 sum of 1 to 4 weeks
A82
B55
C31
D45

 

and when click week 2, then sum 2~5 weeks, 

 sum of 2-5weeks
A92
B35
C31
D65
F25

 and when click week 3, then sum week 3 to 6 and so on..

sample data

dat:
load * inline [ Date, Week, ID, Unit
9/1/2021, 1, A, 10
9/1/2021, 1, B, 20
9/7/2021, 2, A, 32
9/7/2021, 2, C, 31
9/14/2021, 3, A, 20
9/15/2021, 3, B, 25
9/16/2021, 3, D, 20
9/20/2021, 4, A, 20
9/20/2021, 4, D, 25
9/21/2021, 4, B, 10
9/27/2021, 5, A, 20
9/27/2021, 5, F, 25
9/28/2021, 5, D, 20
10/4/2021, 6, A, 25
10/5/2021, 6, B 11
10/6/2021, 6, C, 12
10/11/2021, 7, A, 10
10/11/2021, 7, C, 25]

Labels (2)
1 Solution

Accepted Solutions
AshutoshBhumkar
Partner
Partner

Hello,

Maybe using below expression.

Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)

AshutoshBhumkar_0-1634058994732.pngAshutoshBhumkar_1-1634059017183.png

 

Let us know if that solves your query.

 

Thanks,
Ashutosh

View solution in original post

3 Replies
AshutoshBhumkar
Partner
Partner

Hello,

Maybe using below expression.

Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)

AshutoshBhumkar_0-1634058994732.pngAshutoshBhumkar_1-1634059017183.png

 

Let us know if that solves your query.

 

Thanks,
Ashutosh

View solution in original post

nezuko_kamado
Contributor III
Contributor III
Author

What script I can write,  if  I only want to display IDs that their sums are greater than 50 at the table result?

For example,
week 1-4, only A and B show
week 2-5, only A and D show

 

Thank you!!!

nezuko_kamado
Contributor III
Contributor III
Author

Actually got it. 

if(Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)>50, Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit))