Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
cazztfplease
Creator
Creator

Expression Background Color for Straight Tables

Hi everyone,

I'm fairly sure I am going about this in the hardest way possible, but my logic has me running into walls over and over.  I've found a few threads that have helped me get to where I am currently, but can't seem to get past this point.

I have a straight table that I would like to have up 5 different colors to highlight the background based on various tiers of values.  In the example shown,  I have used an if\else statement to give me two highlights, green and red.  I I know I can use the Visual Cues tab to highlight up to three different ranges.  Ideas on how I can use the expression editor (or other route)  to allow me to highlight 5 ranges of values in different colors? I thought I could structure the statements to allow for (LongEquationValue > 'x' and LongEquationValue <'y') to identify a range for each highlight color, but I may be doing something wrong (clearly) as it doesn't recognize the expression as 'OK'.

For context, each day of the month is a column where the sum of TotalFaults is calculated.  You'll notice a set analysis statement indicating Day ={'1'} for the first of the month, {'2'} for the second, etc.

Thank you for any assistance!

qlikquestion.JPG

qlikquestion2.JPG

15 Replies
cazztfplease
Creator
Creator
Author

Thanks Sunny! Yeah, the num stuff just never got cleaned up from when I was attempting to structure it in the cell a certain way, but I tend to agree with that sentiment.

sunny_talwar

So, did adding Avg(Aggr()) resolved the issue?

cazztfplease
Creator
Creator
Author

I copy/pasted your expression and realized you had 14.825, not 14,825, which was giving me weird numbers I was trying to figure out. (Your expression is the expression I used in in column '1'.)

Now that I see why the numbers were off, I fixed the expression so the numbers look right.  I applied the avg(aggr()) function to column '1', but it did not appear to effect the colors.

This is the cleaned up expression for column '1' with the background color nested if statement applied(below that):

qlikquestion2.JPG

qlikquestion3.JPG

qlikquestion.JPG;

sunny_talwar

You did not apply the new expression for the color expression?

Capture.PNG

You need to apply the Avg(Aggr()) in the above expression

Anywhere you see this

(('14,825') - (sum({$<Day = {'1'}>}TotalFaults)))/('14,825')

Replace it with

Avg(Aggr((('14,825') - (sum({$<Day = {'1'}>}TotalFaults)))/('14,825'), Month))

cazztfplease
Creator
Creator
Author

Sunny,

That worked! Can you explain WHY?!?!?

sunny_talwar

Avg(Aggr()) fixed the total value from -1925.7 to 0.83944... this fixed the comparison and hence the color