Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I’m trying to create a pie chart in Qlik Sense where I want to show both the value and the share for each category.
For example, I have a calculated dimension like this:
=If(
region = 'REGION_A',
If(
buyer = 'BUYER_A'
AND WildMatch(product_type, '*TYPE_01*', '*TYPE_02*'),
'CATEGORY_A',
If(
(
buyer = 'BUYER_A'
AND NOT WildMatch(product_type, '*TYPE_01*', '*TYPE_02*')
)
OR buyer = 'BUYER_B',
'CATEGORY_B',
If(
buyer = 'BUYER_C',
'CATEGORY_C',
If(
buyer = 'BUYER_D',
'CATEGORY_D'
)
)
)
)
)
My measure is:
Count(DISTINCT transaction_id)
Ideally, I want both the value and percentage to be displayed on the pie chart itself, or at least have both available in the tooltip.
What would be the recommended way to achieve this in Qlik Sense? Should I use a custom label expression, a second measure, or another approach?
Thanks!
Hi, that calculated dimension uses values that can be precalculated. I would prefer to modify the script to create the "Category" field. Maybe you need some temporary to join fields from different tables until you can create one with all values, but it seems doable.
Once you have done it, the calculated Expression to show the percentage can be just:
=Aggr(Category &' ('& Num(Count(DISTINCT transaction_id)/Count(TOTAL DISTINCT transaction_id),'#.##0,00%') &')', Category)
Without creating the dimension in the script maybe this also works:
=Aggr([Paste Your Calculated Dimension Here] &' ('& Num(Count(DISTINCT transaction_id)/Count(TOTAL DISTINCT transaction_id),'#.##0,00%') &')', region, buyer, product_type)
But the selections on the chart might be misleading as it will make selections in 3 different fields.
You can also try to create the calcualted dimension as a master dimension.
Hi.
the cleanest approach is to keep your calculated dimension and Count(DISTINCT transaction_id) as the measure, then use the pie chart's label/tooltip configuration rather than creating a second measure just for the percentage.
use one measure for the value + the native pie-chart percentage/relative-value label if your Qlik Cloud version supports it. Use the second percentage measure only if you need a custom tooltip or specific percentage calculation.
Create Two pie Chart with same dimesion and measure and follow the steps below
1.first pie chart show Value
2. in second pie chart show share and add this Chart to master items
3. go to first chart and Add tool tip and add chart from Mater Item.
4. now you have Value in chart and Share on tooltip
please find my video below which describe the same.
Thanks
Hi, that calculated dimension uses values that can be precalculated. I would prefer to modify the script to create the "Category" field. Maybe you need some temporary to join fields from different tables until you can create one with all values, but it seems doable.
Once you have done it, the calculated Expression to show the percentage can be just:
=Aggr(Category &' ('& Num(Count(DISTINCT transaction_id)/Count(TOTAL DISTINCT transaction_id),'#.##0,00%') &')', Category)
Without creating the dimension in the script maybe this also works:
=Aggr([Paste Your Calculated Dimension Here] &' ('& Num(Count(DISTINCT transaction_id)/Count(TOTAL DISTINCT transaction_id),'#.##0,00%') &')', region, buyer, product_type)
But the selections on the chart might be misleading as it will make selections in 3 different fields.
You can also try to create the calcualted dimension as a master dimension.