Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

sum sales by product if year equals

I am new to Qlik so please bear with me.

I want to sum sales expressed as a percentage by product type as dimension if it equals to a certain year for a bar chart.

Here is what I have so far: Sum(if(Year=2018 , [Sales]) / (sum [Sales])

However, it is throwing up a error. Can anyone help please?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I got it to work in the end. I needed to specify the year in the 2nd part of the expression

the expression that worked was: = Sum({< Year = {'2018'} >} [Sales])/Sum(total {< Year = {'2018'} >} [Sales])

View solution in original post

5 Replies
vishsaggi
Champion III
Champion III

You want only sales data to show for 2018? If yes, you can use like

= Sum({< Year = {'2018'} >} Sales)/Sum(TOTAL Sales)

Anonymous
Not applicable
Author

Thanks very much that worked, however my bar chart for all products (dimension) is not summing to 100% for 2018. Is there something missing from the expression?

I am actually summing quantity of products for 2018 but that should not make a difference. I do not understand why it's not summing to 100%

vishsaggi
Champion III
Champion III

Can you share some sample data or a file to work on?

Anonymous
Not applicable
Author

I got it to work in the end. I needed to specify the year in the 2nd part of the expression

the expression that worked was: = Sum({< Year = {'2018'} >} [Sales])/Sum(total {< Year = {'2018'} >} [Sales])

vishsaggi
Champion III
Champion III

‌ok good. Close the thread marking correct helpful response accordingly.