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: 
Not applicable

avg daily sales for last 12 months

Dear experts,

How do I get average daily sales for last 12 months from the month the user has selected using set analysis?

Please help.

Thank you.

Message was edited by: Pramod Karanam

1 Solution

Accepted Solutions
SergeyMak
Partner Ambassador
Partner Ambassador

Something like this

RangeAvg(AGGR(Sum({$<Year={$(='">=" & Year(AddMonths(Max(Date),-12)) & '"')},

Month={$(='">=" & Month(AddMonths(Max(Date),-12)) & '"')}

>}Sales),Month))

But it's better if you share your sample app

Regards,
Sergey

View solution in original post

6 Replies
SergeyMak
Partner Ambassador
Partner Ambassador

Something like this

RangeAvg(AGGR(Sum({$<Year={$(='">=" & Year(AddMonths(Max(Date),-12)) & '"')},

Month={$(='">=" & Month(AddMonths(Max(Date),-12)) & '"')}

>}Sales),Month))

But it's better if you share your sample app

Regards,
Sergey
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=Sum({<DateDimension={'>=$(=MonthStart(Max(DateDimension), -11))<=$(=Date(Max(DateDimension)))'}>}Sales)/Count({<DateDimension={'>=$(=MonthStart(Max(DateDimension), -11))<=$(=Date(Max(DateDimension)))'}>} Distinct DateDimension)

In the above expression replace DateDimension with your date field name.

Regards,

Jagan.

Not applicable
Author

Hai jagan,

I am using a Pivot table... I have attached the format of the pivot table to the main question. Could you please help.

Thank you.

SergeyMak
Partner Ambassador
Partner Ambassador

Hi Pramod,

Could you attach app, not excel?

Regards,
Sergey
jagan
Luminary Alumni
Luminary Alumni

Hi,

What is your expected output in the average Daily Sales Last 12 months?  Can you attach some sample Qlikview file?

Regards,

Jagan.

Not applicable
Author

you could achieve it with selecting the years you want to compare in a listbox and use the year and month as dimension in you pivottable. and then your expression would be avg(sales)

regards,

MT