Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
sogloqlik
Creator III
Creator III

How to calculate Sales Weight

Hello everyone,

I received a requirement to calculate weighted availability, meaning:

The percentage of total sales in the stores where the selected product is sold, out of the total sales across all stores.

The expression needs to be displayed in two charts:

  1. A Bar chart with Sector as the dimension.

  2. A Line chart with Sector and Year as dimensions.

I was able to create the bar chart using the following expression:

({1<[Material]=P({1<[Product_Division]={'10','12','13','16','26','30','35'}>}[Material]), CustKey=P({<[Customers.Name] -= {"*Marlog*"}, [Customer_H6_Desc.]={'Private'}>} CustKey),
, Year = $::Year>}

[Sales])
/
{1< [Material]=P({1<[Product_Division]={'10','12','13','16','26','30','35','40'}>}[Material]), CustKey = P({1<[Customers.Name] -= {"*Marlog*"}, [Customer_H6_Desc.]={'Private'}>}CustKey), Year = $::Year>}
[Sales]

However, I was not able to make it work properly for the line chart.

There are Three additional constraints:

  • [Sales] is already a master measure and cannot be modified.

  • The line chart should ignore Year selection (So the trend will always be visible).

  • There may be selections on different product levels (Category, Barcode, etc.).

  •  

I would appreciate a solution or an alternative expression that might work better in this scenario.

Thanks in advance!

Labels (2)
11 Replies
sogloqlik
Creator III
Creator III
Author

Hi,

The formula works, including for a master measure. I got stuck on trying to use P() and didn’t take a step back to realize that the solution was actually much simpler.

Thanks for the help!

Sunilsahu_345
Contributor II
Contributor II

Thank you for the information.