Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to color a stacked bar chart with red and green and I'm unable to do so I have tried to do it using color by expression. And here are some scripts I've tried:
//Color(IF(training_status = 'Completed', RGB(0, 255, 0)), IF(training_status = 'Pending', RGB(255, 0, 0)))
//=if(TRAINING_STATUS='Completed', RGB(0, 255, 0), RGB(255, 0, 0))
//IF(Count({<TRAINING_STATUS={'Pending'}>} TRAINING_STATUS) > 0, '#4477aa', (IF(Count({<TRAINING_STATUS={'Completed'}>} TRAINING_STATUS) > 0, '#ddc800',) ))
//IF(MeasureName = 'Count(if(TRAINING_STATUS=''Pending'', TRAINING_STATUS))', '#4477aa')
IF(TRAINING_STATUS='Completed', RGB(0, 128, 0), IF(TRAINING_STATUS='Pending', RGB(255, 0, 0)))
Hi @somilkaushik and welcome to Qlik Community.
It would be easier to set your status Pending and Completed as master items, and then in their properties, associate them the colors you like.
Thank you for the suggestion, it worked. But what's the issue in doing it in color by expression?
My measures were:
Complete: count(if(TRAINING_STATUS='Completed',TRAINING_STATUS ))
Pending: count(if(TRAINING_STATUS='Pending',TRAINING_STATUS ))
My expression was:
IF(TRAINING_STATUS='Completed', RGB(0, 128, 0), IF(TRAINING_STATUS='Pending', RGB(255, 0, 0)))
At first sight I would say that in your bar chart, you are showing the count of TRAINING_STATUS, while the color expression is evaluating the values of TRAINING_STATUS, two different things.
I'll have to look at it thoroughly to give you a better answer.
Did you check the box "The expression is a color code"?