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: 
Not applicable

How do I colour the background of negative Sales Variance numbers in a table

Hello everybody,

I've been trying to colour the background of negative Sales Variance % in a table and it has worked in other tables before, but not this time. This is the table  where I want to colour the background red (Sales Variance%):

Skärmklipp2.PNG

The expression for Sales Variance % looks like this:

Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales) - 1

Can anyone tell me how I can write an expression that makes the colour in the background red?

Sincerely,

Betty Habtemariam

Labels (1)
1 Solution

Accepted Solutions
tahirkhalil
Creator
Creator

Hi,

You can use expression background color for this.

In expression, if you click +, you can define background color. In your specific condition you can put:

if( Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales) - 1 < 0, Yellow())

I skipped otherwise (False) condition of IF.

if( Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales) - 1 < 0, Yellow(), Green())

Regards,

TK

View solution in original post

10 Replies
tahirkhalil
Creator
Creator

Hi,

You can use expression background color for this.

In expression, if you click +, you can define background color. In your specific condition you can put:

if( Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales) - 1 < 0, Yellow())

I skipped otherwise (False) condition of IF.

if( Sum({$<Year={$(=Max(Year))}, Mon={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Mon={$(=Month(Today()))}>}Sales) - 1 < 0, Yellow(), Green())

Regards,

TK

Chanty4u
MVP
MVP

manojkulkarni
Partner - Specialist II
Partner - Specialist II

Expand Expression - Select Background Color - put condition like

if (Sales Variance < 0, redcolor())

NareshGuntur
Partner - Specialist
Partner - Specialist

You need to expand the Measure under Data-->Columns-->            and you'll find Background Color Expression like below

Untitled.png

Not applicable
Author

Thank you! I managed to fix the background colour. However, now the problem is that everything is red, whether or not the numbers are positive or negative, haha! It's a neverending story Any thoughts on that?

What it looks like now:

Skärmklipp2.PNG

The expression:

if (Sum({$<Year={$(=Max(Year))}, Min={$(=Month(Today()))}>}Sales) - 

Sum({$<Year={$(=Max(Year)-1)}, Min={$(=Month(Today()))}>}Sales)/

Sum({$<Year={$(=Max(Year)-1)}, Min={$(=mMonth(Today()))}>}Sales) < 0, RGB(255,0,0), red ())

Sincerely,

Betty Habtemariam

reddy-s
Master II
Master II

Hi Betty,

You are making use of the same color when its true as well as when its false.

RGB(255,0,0) is red

So change the colour codes:

Green would be RGB(146,208,80)

Amber would be RGB(255,192,0)

Thanks,

Sangram

Not applicable
Author

Thank you! 😃 It worked!

Not applicable
Author

Thank you! 😃  Sometimes I'm just too blind, haha! Sorry for the late reply. I was away from work a couple of days.

Sincerely,

Betty Habtemariam