Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
venky77777
Contributor III
Contributor III

color coding based on totals

how to write in pivot table if sum(sales) > total sales then green() else red(). I wrote in background color section as if(sum(sales)<sum(total sales),red(),green()) but not getting correct result

Labels (2)
14 Replies
venky77777
Contributor III
Contributor III
Author

venky77777_0-1710347333007.png

chart screenshot posted at above reply

MatheusC
Specialist II
Specialist II

Hi,@venky77777 

You need to adjust your code for the total by its dimension, in your expression the sum takes the total regardless of the city category, for this you need to specify the dimension between <dimension>:

See if this is correct:

if(dimensionality()=1, if(sum(sales)<sum(total <city>sales),red(),green()))

Regarts, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
pravinboniface
Creator II
Creator II

@venky77777 You are not getting colors on the Total line because your expression is not setting values for dimensionality=0

if(dimensionality()=1, if(sum(sales)<sum(total sales),red(),green())   /* Dimensionality=0 has nothing */)

Can you check the values of sum(sales) and sum(total sales) by making them separate columns.  I bet they are equal.  Also, I'm trying to understand the columns del and hyd and how it's interacting.

venky77777
Contributor III
Contributor III
Author

thanks, that's worked on table. here it is..

venky77777_0-1710349430622.png

 

venky77777
Contributor III
Contributor III
Author

Thanks for reply, got result by applying @MatheusC suggested expression