# New to Qlik Sense

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

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for
Did you mean:
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 A 82 B 55 C 31 D 45

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

 sum of 2-5weeks A 92 B 35 C 31 D 65 F 25

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)

• ### Script

1 Solution

Accepted Solutions
Partner

Hello,

Maybe using below expression.

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

Let us know if that solves your query.

Thanks,
Ashutosh

3 Replies
Partner

Hello,

Maybe using below expression.

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

Let us know if that solves your query.

Thanks,
Ashutosh

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!!!

Contributor III
Author

Actually got it.

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

Tags
Community Browser