cancel
Showing results for
Did you mean:
Contributor III

Customize totals in stacked bar chart

Hi there! I am facing an issue with totals in a stacked bar chart.

I have a stacked bar chart with two measures which can be either positive or negative. I need to show for each value of the dimension the sum of these measures.

However, when one is positive and the other negative, qlik differences between sum of positive and sum if negative.

is there any way to avoid it? By the way, is it possible to customize the formar of the total value?

Labels (2)

• QlikWorld 2023

4 Replies
Specialist

Hi, @JohnIssue

What would be the customization of the totals? If you can give examples in more detail.

To avoid negative effects, you can apply axis customization, in the case of the X axis setting the minimum value, see below:

Regarts,
Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Partner - Creator

Hi

In Qlik Sense, a stacked bar chart will by default show the net sum of the measures. That is, it will add up the positive values and subtract the negative ones for each stack in the chart. If you want to show the absolute sum (ignoring the sign), you need to adjust your expression to handle this logic.

Here's how you can modify the measures to achieve this:

1. Create new measures: Instead of using the original measures directly, create new calculated measures that take the absolute value of your measures. For example, if your original measures are `Measure1` and `Measure2`, you would create new measures as follows:

Try...
```Abs(Measure1) Abs(Measure2) ```
2. Total Expression: When adding the total label in the bar chart, you might need to use an expression to calculate the total as the absolute sum of `Measure1` and `Measure2`. This can typically be done in the chart's properties panel where you define the total.

Try...
```Sum(Abs(Measure1)) + Sum(Abs(Measure2)) ```
3. Custom Formatting: To customize the format of the total value, you can use the `Num()` function in Qlik Sense within your expression to format the number as you want. For example:

Try...
```Num(Sum(Abs(Measure1)) + Sum(Abs(Measure2)), '#,##0.00') ```

This will format the number with a comma as a thousand separator and two decimal places.

Here's an example of how you can implement this in a chart expression:

``````// Assuming your dimension is called 'Dimension'
Sum({<Dimension>} Abs(Measure1)) + Sum({<Dimension>} Abs(Measure2))``````

And for the custom total label, you can use the `Num()` function as described above.

Keep in mind that customizing the total label's format might not always be straightforward in the Qlik Sense UI, as it often automatically formats numbers based on the overall chart settings. If the default UI options do not meet your needs, you might have to resort to using a Qlik Sense extension that allows for more customized total labels.

Contributor III
Author