Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jerryr125
Creator III
Creator III

If Statement - color question

Hi - 

I have the following if statement in a KPI:

If($(vAmount) < $(vBudget),'Under Budget',Over Budget')

Works fine.

Question : How to I make 'Under Budget' appear in a green font color and 'Over Budget' appear in red font color ?

Thoughts ?? Thanks - Jerry

1 Solution

Accepted Solutions
lorenzoconforti
Specialist II
Specialist II

use the Dual function in your if statement

If($(vAmount) < $(vBudget),dual('Under Budget',0) ,dual('Over Budget',1))

 

then in your color expression, set your limit to 0.5 and change the colors accordingly

View solution in original post

9 Replies
Anil_Babu_Samineni

Check if text color option for color? If so, you can define

If($(vAmount) < $(vBudget), Green(), Red())

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
jerryr125
Creator III
Creator III
Author

Hi - I would like to text to still appear - I cannot change the conditional color.

thoughts ? 

Anil_Babu_Samineni

KPI will show in single row? May be i am not following, Can u please brief about?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
jerryr125
Creator III
Creator III
Author

The  If statement is set up in the KPI to display either :

Over Budget 

Or 

Under Budget

It displays text

If($(vAmount) < $(vBudget),'Under Budget',Over Budget')

 

How do I get the expression to display 'Under Budget' in green and 'Over Budget' in red ??

 

Thanks - Jerry

jerryr125
Creator III
Creator III
Author

The  If statement is set up in the KPI to display either :

Over Budget 

Or 

Under Budget

It displays text

If($(vAmount) < $(vBudget),'Under Budget',Over Budget')

 

How do I get the expression to display 'Under Budget' in green and 'Over Budget' in red ??

 

Thanks - Jerry

lorenzoconforti
Specialist II
Specialist II

In your KPI object, in the color section, toggle off  "Library colors" and toggle on "Conditional colors"

Change the two colors in the bar that appears underneath according to the colors you need. As a limit value, insert your variable (i.e. = vBudget)

 

Lorenzo

jerryr125
Creator III
Creator III
Author

Hi Lorenzo - here is the message that I am receiving:

 

 

QSMessage.JPG

lorenzoconforti
Specialist II
Specialist II

use the Dual function in your if statement

If($(vAmount) < $(vBudget),dual('Under Budget',0) ,dual('Over Budget',1))

 

then in your color expression, set your limit to 0.5 and change the colors accordingly

jerryr125
Creator III
Creator III
Author

thank you - that did the trick !!

I set the data element to display the "Measure Expression" and changed the colors accordingly - perfect! !