Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Bar chart color not correct

Hello to all the community,

I am trying to color the bars of a bar chart depending on the values that the bars have, like on the example in attachment.

I have a condition on the background color property of the chart. This condition is an if statement:

=if([NumeroIncidenciasMPV]=max(NumeroIncidenciasMaximoMPV,1),Lightred(),Lightgreen())

This is suppose to paint the largest bar with red.

But with this condition all the bars are painted red, but if I use:

=if([NumeroIncidenciasMPV]=4,Lightred(),Lightgreen())

only the first one is red, and this is what I need, but I need the value to be dynamic, so I have to use the expression max(NumeroIncidenciasMaximoMPV,1) or a variable containing its value.

I checked the value of max(NumeroIncidenciasMaximoMPV,1) and it is 4, so I don't understand why this is not working.

Could anyone help?

Thank you!

10 Replies
MK_QSL
MVP
MVP

IF(Rank(SUM{1}NumeroIncidenciasMPV)) = 1, Lightred(), LightGreen())

Not applicable
Author

Tank you!

This works, but only for the first bar. What if I want to make something like on the new attachment?

Example.png

MK_QSL
MVP
MVP

IF(Rank(SUM{1}NumeroIncidenciasMPV),4) = 1, Lightred(), LightGreen())

jsingh71
Partner - Specialist
Partner - Specialist

Use variables and assign the calculated values in your chart.

For your reference please find attachment.

Not applicable
Author

That statement colors the bars one by one.

Is there a way to color all the bars with the same result with the same color, for example:

All the bars with result=4 with red, all the bars with result=3 yellow and so fort.

engishfaque
Specialist III
Specialist III

Dear Ivo,

Solved problem, please check attached screenshot.

Bar-Color-Change.png

Kind regards,

Ishfaque Ahmed

Not applicable
Author

Hello Ishfaque,

Consider this, what if the value 27 comes from a variable and this variable contains a dynamic value that comes from an expression, for example a max(FIELD) expression.

Because I tried to do this (with the variable) and does not work, all the bars are painted the same color.

engishfaque
Specialist III
Specialist III

Dear Ivo,

Please find attached screenshots.

1.png2.png3.png

Kind regards,

Ishfaque Ahmed

Not applicable
Author

Thank you for the reply Ishfaque,

I follow all the step you showed me, the only difference is that you set the value 27 to the variable and I set the expression:

max(NumeroIncidencias)

and with this all the bars are colored red... I have a textfield on the side of the chart to check the value of my $(maximoIncidencaisMPVA) and the value is 4.00000000... Could this influence the if statement?

A.png

B.png

C.png