Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
NEW webinar Dec. 7th: 2023 Outlook, A Pivotal Year for Data Integration SIGN ME UP!
cancel
Showing results for 
Search instead for 
Did you mean: 
rm1
Contributor III
Contributor III

Calculate sales percentage based on a group of selected products: denominator issue

Hi Everyone

I'd need some help with the following expression. I need to select some products and then calculate the percentage of sales based on the current selection --> sales of selected products / Total sales of selected product lines. Nothing difficult. But every product belongs to a different product line. 

product 1 --> product line 1

product 2 --> product line 2

product 3 --> product line 3

So, if I select only product 1 and product 2, I'd need in the denominator only the total of product line 1 and product line 2.

Formula: sum({$<year={2019}>} [quantity product]) / sum({<year={2019}, Product=>} total [quantity product]) doesn't work because it returns to me a denominator with ALL the values including the product line 3.

Is there anyone that can help me? 

Thanks a lot in advance!

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

May be this

Sum({$<year = {2019}>} [quantity product])
  /
Sum({$<year = {2019}, Product, ProductLine = p(ProductLine)>} [quantity product])

Or this if you are doing this in a chart where ProductLine is a dimension

Sum({$<year = {2019}>} [quantity product])
  /
Sum({$<year = {2019}, Product, ProductLine = p(ProductLine)>} TOTAL <ProductLine> [quantity product])

 

View solution in original post

2 Replies
sunny_talwar

May be this

Sum({$<year = {2019}>} [quantity product])
  /
Sum({$<year = {2019}, Product, ProductLine = p(ProductLine)>} [quantity product])

Or this if you are doing this in a chart where ProductLine is a dimension

Sum({$<year = {2019}>} [quantity product])
  /
Sum({$<year = {2019}, Product, ProductLine = p(ProductLine)>} TOTAL <ProductLine> [quantity product])

 

rm1
Contributor III
Contributor III
Author

it worked perfectly.

Thanks a lot!