Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating values grouped by

Hello,

I'm having a bit of an issue when i try to calculate per product within the dimension year.

product_nr  | sale_price | year           product_nr | sales_target | year

     1          |     5           | 2004                 1       |        10         | 2004

     1          |     6           | 2005                 1       |         5          | 2004

     2          |     10         | 2004                  2      |         3          | 2004

What i want as outpur is:

year | expected_sales

2004|     105

so  5*15+3*10+ etc.....

i have tried with aggr but no luck with this expression:

sum(Aggr(NODISTINCT sum(FORECAST_expected_volume) * ORDER_unit_price, PRODUCT_number))

I am problably doing something wrong. I would really appreciate some help.

1 Solution

Accepted Solutions
Not applicable
Author

This expression still gives me wierd results. It is far to complicated for me to understand it to .

I used this expession to make it work.

sum(AGGR(ORDER_unit_price*sum(FORECAST_expected_volume),YEAR_nr,PRODUCT_number))

Thanks for your time, i really appreciate it.

View solution in original post

4 Replies
MK_QSL
MVP
MVP

sum(AGGR(SUM(DISTINCT sale_price) * SUM(Distinct sales_target),product_nr))

OR

sum(AGGR(SUM(DISTINCT sale_price) * SUM(sales_target),product_nr))

Not applicable
Author

Thank you, i found this works but only when i select the year in a select box. I hope this image will show the new problem.

1.PNG.png

The value is correct at image 2, so 38,263,344.28 that is when i select the year in the list box.

At image 1, when i dont select anything, it shows 107,012,480.16 and that is not correct.

Should i add the year to the aggr? I dont know if that is possible.

MK_QSL
MVP
MVP

=SUM(Aggr(SUM({<year = {"=sum(sales_target) <> 0"}>}sale_price) * SUM({<year = {"=sum(sale_price) <> 0 "}>}sales_target),product_nr))

Not applicable
Author

This expression still gives me wierd results. It is far to complicated for me to understand it to .

I used this expession to make it work.

sum(AGGR(ORDER_unit_price*sum(FORECAST_expected_volume),YEAR_nr,PRODUCT_number))

Thanks for your time, i really appreciate it.