Skip to main content

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

cancel
Showing results for 
Search instead for 
Did you mean: 
jerryr125
Educator-Ambassador
Educator-Ambassador

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())

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
jerryr125
Educator-Ambassador
Educator-Ambassador
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?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
jerryr125
Educator-Ambassador
Educator-Ambassador
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
Educator-Ambassador
Educator-Ambassador
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
Educator-Ambassador
Educator-Ambassador
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
Educator-Ambassador
Educator-Ambassador
Author

thank you - that did the trick !!

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