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

Avg of sales

Hi ,

Could someone pls help me in getting this scenario. I have 20 products in Product Field where i want to get the avg sales of this week and last week by each product in a chart.

Thnx,

John

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Current Week

Avg(Aggr(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today())))<=$(=Date(WeekEnd(Today())))"}>}Sales),Product))

or

Simply

Avg(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today())))<=$(=Date(WeekEnd(Today())))"}>}Sales))


Last Week

Avg(Aggr(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today()-7)))<=$(=Date(WeekEnd(Today()-7)))"}>}Sales),Product))

or

Simply

Avg(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today()-7)))<=$(=Date(WeekEnd(Today()-7)))"}>}Sales))

View solution in original post

6 Replies
MK_QSL
MVP
MVP

Current Week

Avg(Aggr(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today())))<=$(=Date(WeekEnd(Today())))"}>}Sales),Product))

or

Simply

Avg(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today())))<=$(=Date(WeekEnd(Today())))"}>}Sales))


Last Week

Avg(Aggr(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today()-7)))<=$(=Date(WeekEnd(Today()-7)))"}>}Sales),Product))

or

Simply

Avg(SUM({<InvoiceYear = , InvoiceQuarter = , InvoiceMonth =, InvoiceWeek = , InvoiceDate = {">=$(=Date(WeekStart(Today()-7)))<=$(=Date(WeekEnd(Today()-7)))"}>}Sales))

avinashelite

Try like this:

Dimension: Product

Expression: current week:

                   if(week(your_date_column)=week(today()) ,avg(sales))

                   previous week:

                    if(week(your_date_column)=week(today())-1 ,avg(sales))

this should solve the problem

ramoncova06
Partner - Specialist III
Partner - Specialist III

Manish solution should work with what you are asking for

Anonymous
Not applicable
Author

Sorry Guys, I missed few points here the data is not being reloaded every day...its like every three days ..usually every monday &  Thursday. So how do we go in this situation

Thnx,

John

MK_QSL
MVP
MVP

Doesn't matter how frequently your data is being loaded. That will not make change on This week or last week.

Anonymous
Not applicable
Author

Thanks Manish

Thnx,

John