Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
solomonadjei
Contributor III
Contributor III

IF EXPRESSION

Happy New year everyone, I hope everyone had a good time.

 

Could someone please advise what am I doing wrong in the below expression.

if([Trust Spend] = "Actual Trust Spend",Green(), Red())

 

The “Actual Trust Spend” is a label not a field name and I keep getting : RGB(0,128,0) as an answer.  

1 Solution

Accepted Solutions
sunny_talwar

You sure can, but what you need to do is to use your expression as a background color expression and not just the main expression. Does that make sense?

View solution in original post

10 Replies
MohammedMustaq
Partner - Creator
Partner - Creator

Happy New Year dear!

Try with Single Quotes instead of Double " "

=if([Trust Spend] = 'Actual Trust Spend',Green(), Red())

 

Regards

Mustaq

solomonadjei
Contributor III
Contributor III
Author

Thanks for your rapid respond Mustaq.
Still not working 😞
MohammedMustaq
Partner - Creator
Partner - Creator

 

Can you attach the sample data with your desired output.

it would  be easy to understand and solve.

Regards

Mustaq

solomonadjei
Contributor III
Contributor III
Author

Hi Mustag,
I have attached image of the view.
bgerchikov
Partner - Creator III
Partner - Creator III

If  Actual Trust Spend is a column label, same as Trust Spend. Should be like this:

if([Trust Spend] = [Actual Trust Spend],Green(), Red())

 

Good luck!

solomonadjei
Contributor III
Contributor III
Author

Thanks for your input

The [Actual trust spend] is a label name in the chart properties and am not getting the result am looking for.

sunny_talwar

What are you hoping to see here? You have used a color expression as a main expression.... So, because Trust Spend <> Actual Trust Spend... you are seeing the RGB() representation of Red(). What are you looking to get?
solomonadjei
Contributor III
Contributor III
Author

Morning Sunny,
Am hoping to see if any number in the [Actual Trust Spend] field does not match with the Trust Spend should turn RED and a direct match should turn GREEN. The issue I have here is that, the [Actual Trust Spend] is not a field name in the table, it’s just a label name in the chart properties tab. Is there a way o can achieve this ?
Thanks
sunny_talwar

You sure can, but what you need to do is to use your expression as a background color expression and not just the main expression. Does that make sense?