Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Melissa2
Contributor II
Contributor II

Background Colour Expression

Hi guys

I need some assistance.  I think I might be missing something in my expression I am trying to incorporate my IF statement to change negative % to Red and positive to Green.

Below is my expression

if(

Sum({<Year = {$(vMaxYear)} >} NetSalesValue)-Sum({<Year = {$(vMaxYear)} >} CostValue)
/
Sum({<Year = {$(vMaxYear)} >} NetSalesValue)

-

Sum({<Year = {$(vMaxYear)} >} [GP Budget])
/
Sum({<Year = {$(vMaxYear)} >} [NetSalesValue Budget])

>=0.01,'Green','Red')

Without the IF my expression works perfectly, but when I incorporate my IF statement, you can see below how it apply the background colour.  

Melissa2_0-1657618001590.png

What am I doing wrong?

Regards,

Melissa

Labels (1)
1 Solution

Accepted Solutions
ggijben
Partner - Creator II
Partner - Creator II

Hi @Melissa2 , 

Can you try:

IF( ("Variance") <0, red(), green())

View solution in original post

4 Replies
Mark_Little
Luminary
Luminary

HI there, 

Syntax looks ok, but might be down to the dimensionality. Try the below.

if(

(

Sum({<Year = {$(vMaxYear)} >} NetSalesValue)-Sum({<Year = {$(vMaxYear)} >} CostValue)
/
Sum({<Year = {$(vMaxYear)} >} NetSalesValue)

-

Sum({<Year = {$(vMaxYear)} >} [GP Budget])
/
Sum({<Year = {$(vMaxYear)} >} [NetSalesValue Budget])

)

>=0.01,'Green','Red')

Melissa2
Contributor II
Contributor II
Author

Hello Mark

 

I have tried that as well and see below the results.  I am really baffled by this one 🙂 

Makes almost all negatives green and then a few random one's red....

Melissa2_0-1657623659084.png

 

ggijben
Partner - Creator II
Partner - Creator II

Hi @Melissa2 , 

Can you try:

IF( ("Variance") <0, red(), green())
Melissa2
Contributor II
Contributor II
Author

Brilliant, thanks man!