Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

rolling for 5 days?


date,amount

1/1/2014,100

2/1/2014,200

4/1/2014,300

5/1/2014,400

6/1/2014,500

7/1/2014,

8/1/2014,700

9/1/2014,

10/1/2014,900

11/1/2014,1000

12/1/2014,

13/1/2014,1200

14/1/2014,1300

15/1/2014,1400

here i want calculate for rolling 5 days avg for sum(amount)  ?

how to calculate it?

1 Solution

Accepted Solutions
SunilChauhan
Champion II
Champion II

Rangesum(above(sum(amount),0,5))/5

Sunil Chauhan

View solution in original post

11 Replies
rubenmarin

Hi, please check attachment, hope this helps

Anonymous
Not applicable
Author

i am using personal edition pls give me expression here

PrashantSangle

Hi,

Try like

Avg({<Datefield={">=$(=Date(max(date)-5))<=$(=Date(max(date)))"}>}Sales)

IF dateField is not in date format then use below code in script to convert it into date

Date(Date#(date,'DD/MM/YYYY'),'DD/MM/YYYY')

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
SunilChauhan
Champion II
Champion II

=Avg({<date={">=$(=Date(max(date)-5)))"}>}amount)

Sunil Chauhan
Gysbert_Wassenaar

See this document: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

it will give for only max date .

in my above data for every date it should calculate rooling avg

SunilChauhan
Champion II
Champion II

Rangesum(above(sum(amount),0,5))/5

Sunil Chauhan
Anonymous
Not applicable
Author

what is the representation of   '0'   here 

SunilChauhan
Champion II
Champion II

you could use 0 using if

using if (len(amount)=0,0,amount);

or null handling

NullAsValue amount;

Set NullValue = 0 ;

hope this helps

Sunil Chauhan