Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Custom bar chart coloumn based on reference line

Hi Community,

I would like to ask if this is possible in bar chart.

My chart is like this:

error loading image

I want to change the color of the part of the bar that exceeds the reference line like this:

error loading image

Is this possible? Any idea or help is much appreciated.

Thanks!

Nadsky

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Custom bar chart coloumn based on reference line

Hi!

As far as I know, this cannot be done directly but there are workarounds.

The simplest would be to make a stacked bar chart:

Assuming your expression in the chart is sum(Allocation) and your reference line is set at referenceValue, you can create two expressions, one for the blue part and one for the red part.

First expression: min( sum(Allocation), referenceValue) - The "min" prevents the bar from growing over the reference line

Second expression: max(sum(Allocation) - referenceValue, 0) - If the original expression value is less or equal to the reference line, we get a value of 0, otherwise we get the part that exceeds the reference line

By coloring the first blue and the second red, you get the desired effect. I think my solution would not work with negative or mixed sign values, but shouldn't be too hard to modify for that case also.

Hope this helps!

-Christian

View solution in original post

4 Replies
Highlighted
Partner
Partner

Custom bar chart coloumn based on reference line

Hi!

As far as I know, this cannot be done directly but there are workarounds.

The simplest would be to make a stacked bar chart:

Assuming your expression in the chart is sum(Allocation) and your reference line is set at referenceValue, you can create two expressions, one for the blue part and one for the red part.

First expression: min( sum(Allocation), referenceValue) - The "min" prevents the bar from growing over the reference line

Second expression: max(sum(Allocation) - referenceValue, 0) - If the original expression value is less or equal to the reference line, we get a value of 0, otherwise we get the part that exceeds the reference line

By coloring the first blue and the second red, you get the desired effect. I think my solution would not work with negative or mixed sign values, but shouldn't be too hard to modify for that case also.

Hope this helps!

-Christian

View solution in original post

Highlighted
Not applicable

Custom bar chart coloumn based on reference line

Hi Christian,

Thanks for the idea of using stack bar chart. The min max function seem not working on my expression (allocation is a formula sum(field1)/sum(field2) ). I used if-else condition instead.

Thanks for helping me out! 😄

Highlighted
Partner
Partner

Custom bar chart coloumn based on reference line

Glad that my suggestion got you on the right track.

Did you try to put the sum(filed1)/sum(field2) part into the min or max functions?

Highlighted
Partner
Partner

Custom bar chart coloumn based on reference line

Now i realized that you actually have to use the rangemin and rangemax functions instead of min and max. That way you get it working without the if statements.