Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
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)
1 Solution

Accepted Solutions
MatheusC
Specialist
Specialist

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!

View solution in original post

14 Replies
pravinboniface
Creator II
Creator II

@venky77777 What do you mean when you say that you are not getting correct results?

Maybe sum(sales) is equal to sum(total sales).  So if you are swapping < and > to test, you may be getting the same result.

David_Friend
Support
Support

@venky77777 when posting be sure to specify what Qlik software you are using (and the version) we have multiple products so be sure to specify QlikView, QlikSense, Qlik Cloud, or NPrinting thanks!

venky77777
Contributor III
Contributor III
Author

yes i done, but the problem is getting color for totals and also getting all red or all green based <or>Screenshot pivot.png

venky77777
Contributor III
Contributor III
Author

sure. thanks for reply

JonnyPoole
Former Employee
Former Employee

Something like this to highlight totals?

 

JonnyPoole_0-1710266620852.png

 

JonnyPoole_1-1710266719810.png

 

SemBL83
Partner Ambassador
Partner Ambassador

Hi,

Try DIMENSIONALITY(). There's a help article with an example that will tell you everything about this function. This will allow you to define a different color scheme on different levels.

Does this help you with your question?

Dimensionality - chart function | Qlik Sense on Windows Help

With kind regards,

Sem

venky77777
Contributor III
Contributor III
Author

when i wrote in background color section if(dimensionality()=1, if(sum(sales)<sum(total sales),red(),green())), getting table as below but not getting green color

venky77777_0-1710346395808.png

 

venky77777
Contributor III
Contributor III
Author

thanks for reply, i applied but I'm not getting 2 colors

JonnyPoole
Former Employee
Former Employee

send a screenshot of the result as well as the expression you used