Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
cancel
Showing results for 
Search instead for 
Did you mean: 
rahulsingh12
Contributor III
Contributor III

Rolling 30 Day Sum

Hi,

I have a situation where I have sales for at a daily level starting from Jan 2020 to date at an SKU level. I want to show in the chart the months and the sales against it. The only condition is that it should always be the next 30 days sales.

For example: 

Jan ( 1st as nothing is selected)- Jan 30th : 2000

Feb(1st as nothing is selected)- Feb 29th :4000

and so on. As soon a user selects a day the bracket of 30 days should shift

The user selects 15 as a day:

Jan ( 15th)- Feb 15thth : 7000

Feb(15th)- Mar 16th :5000

 
 

In the below example I have selected 19th March but I get April (as the bracket is from 19th Mar - 19th Apr) also a month in the month which I don't want. I want the whole sum of 436932 in Mar bracket

 I used the below set analysis

sum({<TRENDDATEMONTH={">$(=$(vL3MEndNew))<=$(=$(vRollingDays))"}>}[DAILY_SALES(Cases)])

vL3MEndNew: 19TH March

vRollingDays: 19th+30 days 

 

Can it be done using set analysis or do I have to write it in script??

 

3 Replies
rubenmarin

Hi, I'm not sure of what you want and what are you getting.

Maybe you need to if¡gnore selections in selected month so only set analysis applies?

sum({<TRENDDATEMONTH={">$(=$(vL3MEndNew))<=$(=$(vRollingDays))"}, MonthFieldToIgnore>}[DAILY_SALES(Cases)])

Also, I would try to make the variable to return the values I want to usetoa ovid the double $(, like setting the content of vRollingDays variable to: =$(vL3MEndNew)+30

Brett_Bleess
Support (Former)
Support (Former)

If Ruben's post got you what you needed, please be sure to close the thread by using the Accept as Solution button on his post.  This gives him credit for the help and lets other Members know it worked.  

The only additional thing I have to try to help is the following Design Blog post:

https://community.qlik.com/t5/Qlik-Design-Blog/The-As-Of-Table/ba-p/1466130

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
wale_martins
Contributor III
Contributor III

Hi,

I suppose that you are using 'Month' as dimesion value, so I would add a calculated dimension and then I would create a single expression.

Dimension:

=aggr(only({<TRENDDATEMONTH={">$(=(vL3MEndNew))<=$(=(vRollingDays))"}>} YourMonthDimension),YourMonthDimension)

Expression:

=Sum(DAILY_SALES)

 

I normally use it like that. The difference is that in my case I always create a variable 'vRolling' and I use an input box to select the number of days, month, years that I want to select backwards or forwards.

 

Example considering the number of 'vRollingMonth' backwards "selected in an input box" from month(today)

=aggr(only({<DATE_OPERATION={">=$(=monthstart(today(),-vRollingMonth))<=$(=monthend(today()))"}>}ID),ID)

 

Hope that works for you.