Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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]
Hello,
Maybe using below expression.
Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)
Let us know if that solves your query.
Thanks,
Ashutosh
Hello,
Maybe using below expression.
Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)
Let us know if that solves your query.
Thanks,
Ashutosh
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!!!
Actually got it.
if(Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit)>50, Sum({<Week = {">=$(=Max(Week)) <=$(=Max(Week)+3)"}>}Unit))