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

How can I create a % calculation based on a COUNT expression?

I have a chart with a field 'Approval Status' and an expression 'COUNT(DISTINCT SKU_NUMBER)' which gives a count of DISTINCT sku_numbers for each value of approval_status. The field approval_status has 2 values 'Approved' and 'Unapproved'. So the count will give me the no. of SKUs for each of the 2 values of approval status. Now I need a % calculation which gives percentage of no. of distinct SKUs  of the total no. of distinct SKUs for each value of approval status.

As an example, if 'Approved' has 60 SKU count and Unapproved has 40 SKU count, the % for approved will be 60% and for unapproved will be 40%.

How do I calcualte this percentage in a pivot chart?

Thank you,

Viral

5 Replies
Nicole-Smith

Is Approval Status a dimension?  If so, then your expression should be:

COUNT(DISTINCT SKU_NUMBER)/COUNT(TOTAL DISTINCT SKU_NUMBER)

SunilChauhan
Champion
Champion

COUNT(DISTINCT SKU_NUMBER) / COUNT(all SKU_NUMBER)

try this hope this helps

Sunil Chauhan
MK_QSL
MVP
MVP

Something like below...

Use this in Text Object

='Approved = '&NUM(COUNT({<[Approval Status] = {'Approved'}>}DISTINCT SKU_NUMBER)/COUNT(TOTAL DISTINCT SKU_NUMBER),'#,##0.00%') & CHR(10) &

'Unpproved = '&NUM(COUNT({<[Approval Status] = {'Unapproved'}>}DISTINCT SKU_NUMBER)/COUNT(TOTAL DISTINCT SKU_NUMBER),'#,##0.00%')

If you want to use in chart..

Approved

= COUNT({<[Approval Status] = {'Approved'}>}DISTINCT SKU_NUMBER)/COUNT(TOTAL DISTINCT SKU_NUMBER)

Unpproved

= COUNT({<[Approval Status] = {'Unapproved'}>}DISTINCT SKU_NUMBER)/COUNT(TOTAL DISTINCT SKU_NUMBER)

Not applicable
Author

This works fine.

Thank you.

Nicole-Smith

Please mark correct and helpful answers so others can find solutions to similar problems