Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
v_jaideep
Creator
Creator

If statement for background color

Hello,

Need help in setting the background color right using the if statement.

If(curreny='USD', (column(1)-column(2))/column(2)>0,green(),red())

or 

If(curreny<>'USD', (column(1)-column(2))/column(2)>0,green(),red()) 

I need to get this right.

Currently the if statement I have works when currency selection is not USD but when I select 'USD' the color representation is wrong

7 Replies
Or
MVP
MVP

This doesn't look like it's valid Qlik syntax. Your if() statement has four arguments and Qlik only accepts three- if(Condition,Then,Else).

What exactly are you trying to achieve?

Digvijay_Singh

If(curreny='USD' and (column(1)-column(2))/column(2)>0,green(),red())

stevejoyce
Specialist II
Specialist II

This would be the syntax, did you just send an example?  it looks like = USD & <> USD both have the same logic so you must want to do something different if you are trying to split them out. 

If(curreny='USD',

    If((column(1)-column(2))/column(2)>0,green(),red())

,If(curreny<>'USD',  If((column(1)-column(2))/column(2)>0,green(),red())

)

v_jaideep
Creator
Creator
Author

I need below statement  if currency selected is USD 

( sum(distinct{<Price= {'Current'}>} sales_USD))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))>0, green(),red())

if currency selected is  EUR

( sum(distinct{<Price= {'Current'}>} sales))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))

>0,green(),red())

 

 

Digvijay_Singh

May be something like this ( ensure expressions are properly formatted)  - 

Pick(Match(Currency,'USD','EUR'),

( sum(distinct{<Price= {'Current'}>} sales_USD))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))>0, green(),red()),

( sum(distinct{<Price= {'Current'}>} sales))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))

>0,green(),red())

)

Digvijay_Singh

I think you missed 'If' before your expression.

Digvijay_Singh

Pick(Match(Currency,'USD','EUR'),

if(( sum(distinct{<Price= {'Current'}>} sales_USD))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales_USD))>0, green(),red()),

if(( sum(distinct{<Price= {'Current'}>} sales))-( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))
/
( sum(distinct{<Price= {'Launch'}, Date= , MonthYear=>} sales))

>0,green(),red())

)