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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Bode-IT
Contributor
Contributor

Average of cumulated values between dates

Hi,

I wonder if it is possible to use 2 aggregations.

My base values are a SUM(Sales)  for a specific date and I need to sum each day between 2 dates and take an average of that list of Sum's.

Something like that, which is not working

AVG(SUM(IF(Date <= addmonths(Today(),-12),Sales,Null())) and SUM(IF(Date <= addmonths(Today(),-13),Sales,Null())))

 

Thank you very much.

 

1 Reply
AG-gugelbisolutions
Creator II
Creator II

I would try with something like

avg( {$< Date={">=$(vStartDate)<=$(vEndDate)"} >}
	aggr( sum( {$< Date={">=$(vStartDate)<=$(vEndDate)"} >} Sales ) ,Date )
)

Of course, you need to calculate vStartDate and vEndDate in the first place.

Aggr is a very powerful function and, basically, lets you iterate the result of and expression over the values of a field (or a series of fields), giving back an array of results to be further aggregated (in this case by avg).

Hope it helps