Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
cdy1
Contributor II
Contributor II

Script Average all values that have bigger dates

Hi, 

I have a set of data that includes dates and amounts. For each date on the script i need to calculate a fielad that has an average of all amount that have dates bigger or equal to the date of the row. Every day a value will be added so the last date will be moving and all the averages will be recalculated. 

I leave an example in the uploaded excel. 

Thanks! 

 

Labels (3)
1 Reply
Kushal_Chawda

@cdy1  if you have unique records per each day then try below. If you don't have unique records per date then you first need to create aggregated table which holds unique records per each date, then you can try below method

Data:
LOAD date, 
     amount
FROM
[qlik avg below.xlsx]
(ooxml, embedded labels, table is Sheet1);

Final:
LOAD *,
     Accum/RowNo() as Avg_Amt;
LOAD *,
     rangesum(amount,peek('Accum')) as Accum
Resident Data
Order by date desc;

DROP Table Data;

DROP field Accum;
Community Browser