Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
luca_bellotti
New Contributor III

Week day year Average

Hello everyone,

I have the following tables:

Sales:
LOAD

ID,
Shop,
Category,
Date,
Sales;

Calendar:

LOAD

Date,
WeekDay,
NrWeek;

 What I need to get is an average per week day of the whole year.

In the app I've created a table to check everyday if some sales are missing from the dataset:

table.PNG

Aside I created another table where I would like to have the average per week day:

Result.PNG

AvgSales = Avg(Aggr(Sum(Sales),WeekDay)

As you can see this is not the average but the sum.

What can I do to get the average?

 

Thanks in advance.

 

 

Labels (3)
10 Replies
zzyjordan
Contributor II

Re: Week day year Average

Hi, Luca

try this
AvgSales = Avg(Aggr(Sum(Sales),Date)

ZZ
luca_bellotti
New Contributor III

Re: Week day year Average

It doesn't work.

result1.PNG

rbartley
Contributor III

Re: Week day year Average

Hi Luca,

 

Perhaps I'm missing something, but if you only display the WeekDay and Sales in the table, all you need is to us Avg(Sales), no need for the Aggr() function.

 

Average2.PNG

 

Average.PNG

 

luca_bellotti
New Contributor III

Re: Week day year Average

Hi Rbartley,

the problem is that the db has sales for every category of every shop in everyday, so if I do a simple average it shows the average of category per day:

result1.PNG

What I need is the total average for eache  weekday.

rbartley
Contributor III

Re: Week day year Average

Ok, could you please post your app (remove of obfuscate any sensitive data if necessary)?  You will need to zip it in order to post it as there is a bug on the Qlik Community site that prevents one from uploading the qvf files.

rbartley
Contributor III

Re: Week day year Average

Take a look at the attached app (you'll have to unzip it).  I've included category in the data and if I use Avg(Sales) with just WeekDay in the table, the formula still works since Qlik Sense calculates it on the context of the dimensions in the table.  I've also added another table which also includes category and in which I've used the formula: Aggr(Avg(Sales),WeekDay).  This shows the same average figures too.

AverageByDayIncCategory.PNG

 

luca_bellotti
New Contributor III

Re: Week day year Average

Here you can find my app.

rbartley
Contributor III

Re: Week day year Average

How about this? 

=Aggr(Sum(Sales),WeekDay)/Count(WeekDay)

AvSalesWeekDayUsingCount.JPG

 

 

luca_bellotti
New Contributor III

Re: Week day year Average

No, the correct result should be this:

result1.PNG

Community Browser