Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregating averages (Sum/Count)

Hi all,

Please is there any reason why the following will not work? It works if I calculate the sales average (sum/count) of each product separately; however, it does not work if I try to aggregate the sales average of both products. Am I missing an aggregate function?

=Num(sum({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1'}>} Sales)/

Count({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1'}>} Sales

+

sum({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 2'}>} Sales)/

Count({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 2'}>} Sales),'##%')

Regards

1 Solution

Accepted Solutions
Kushal_Chawda

May be like below

Num(sum({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1','Product 2'}>} Sales)/

Count({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1','Product 2'}>} Sales),'##%')

View solution in original post

9 Replies
t_chetirbok
Creator III
Creator III

Hi!

What dimension are you use?

Post some example qvw, please.

Not applicable
Author

Hi,

The dimension is Sales

Unfortunately, I can not post the qvw.

Anonymous
Not applicable
Author

try this:

=Num(

((sum({<Sale_Date={'>=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))'}, ProductType={'Product 1'}>} Sales)

/

Count({<Sale_Date={'>=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))'},ProductType={'Product 1'}>} Sales))

+

(sum({<Sale_Date={'>=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))'},ProductType={'Product 2'}>} Sales)

/

Count({<Sale_Date={'>=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))'},ProductType={'Product 2'}>} Sales)))

,'#.##')&'%'

Anonymous
Not applicable
Author

also make sure Format of your expression and SalesDate should be same...

Kushal_Chawda

May be like below

Num(sum({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1','Product 2'}>} Sales)/

Count({<Sale_Date={">=$(=Max(Sale_Date)-30)<=$(=Max(Sale_Date))"},ProductType={'Product 1','Product 2'}>} Sales),'##%')

t_chetirbok
Creator III
Creator III

So, do you want to get a straingt table with Sales as dimension ans sum Sales as expresion?

Anonymous
Not applicable
Author

Sales is your dimension???

Which chart you are using?

Not applicable
Author

This works perfectly well.

Thanks a lot

Regards to all.

Kushal_Chawda

I am glad that it is helpful.