Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
BerryStraw
Contributor
Contributor

Text colour expression based on variable

Hey all,

a question regarding changing the colour of the text in a table. I have a complex master measure including several set analysis conditions. I have a variable which represents the title of the master measure.

So variable1: 'Difference # '&Max(Year)&' - '&Max(Year-1)

In the master measure the label expression is: =$(variable1)

In the table everything works fine, the master measure calculates correctly and the label adapts properly. Now I want to colour the values when they are above 0 green and below red.

So my text color expression the table is:

if($(variable1)>0),green(),red())

And I also tried:

if([$(variable1)]>0),green(),red())

Sadly this doesn't seem to reference the label and therefore doesn't color anything. I cannot use the Column(ColumnNo) option because of hidden and changing columns. The above seemed like a solid option.

Is there anyway to give visual cues based on the outcomes of the master measure?

Thanks

 

Labels (2)
5 Replies
Diter
Contributor III
Contributor III

Hi Barry,

Maybe you can try this way.

if($(variable1)< 0, 'red', Green()) or if(($(variable1))< 0, 'red', Green())

regards,

BerryStraw
Contributor
Contributor
Author

Hey,

thanks for your suggestion. I tried this, but it doesn't get the desired result.

Basically what I want is an excel like conditional formatting. Above 0 is green and below 0 is red.

Thanks

 

Diter
Contributor III
Contributor III

If  you want me to help you trying other ways please share some data with me.

 

regards,

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

In Qlik Sense you can not refer an expression name  within other expression.

So in your case you can not use the Expression Label in Color expression.

For this, you need to write entire expression in if condition.

 

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
BerryStraw
Contributor
Contributor
Author

That is really too bad. Is there like a common or best practise for using a conditional formatting like solution in Qlik Sense? Maybe avoid using master measures and use variables instead? Doesn't seem very logical though.

Any others?