Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Our user wants to be able to see on the legends of a Bar Chart, the Sales Value and the % of participation on the Total Sales of that value. Something like this:
Sales: $2,5 M, 22,5%
Is it possible on Qlik Sense? If so, How?
Thanks a lot.
René.
Yes, this is possible in Qlik Sense, but not directly through the legend settings. In Qlik Sense, the legend displays the dimension values only, and it does not allow measures to be added to the legend label automatically.
To achieve the desired result (showing Sales value and its % contribution to total sales), you can create a calculated dimension that concatenates the dimension value with the required calculations.
However, aggregation functions like Sum() cannot be used directly inside a dimension. For that reason, the aggregation must be wrapped inside an Aggr() function so that Qlik evaluates the measure at the dimension level.
For example, if the dimension is Sub-Category, you can use the following calculated dimension:
=[Sub-Category] & ' - Sales: ' &
Num(Aggr(Sum(Sales), [Sub-Category]),'$#,##0,,.0M') &
', ' &
Num(Aggr(Sum(Sales), [Sub-Category]) / Sum(TOTAL Sales),'#,##0.0%')
Let me explain this for better clarification:
Aggr(Sum(Sales), [Sub-Category]) calculates the total sales for each [Sub-Category].
Sum(TOTAL Sales) calculates the overall total sales across all [Sub-Category].
Dividing the two gives the percentage contribution of that [Sub-Category]to the total sales.
The Num() function is used to format the values (for example, sales in millions and percentage format).
This calculated dimension will allow the legend to display values like:
Chairs – Sales: $2.5M, 22.5%
Binders – Sales: $3.1M, 27.8%
Hope this helps.
Hi,
First of all, thanks for your suggestion.
It works fine for a table Chart, but for a Bar Chart it does not...
Any idea of why?
Thanks again...
René.
Hey,
Under the Appearance section, go to Colors and legend, disable Custom colors, and select the dimension @rahatqayyum08 shared. After doing this, you should see the custom dimension reflected in both the labels and the legend (see the screenshot below).
For this to work, you’ll need to add a measure to the bar chart, as a y-axis is required. I simply added Sum([value]), but you could use, for example, Sum([Sales]).
Hope this works for you.
Regards,