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

a dynamic colour in a line chart

Hello! Can you tell me please, what am doing rong? I wanted the line to be blue if the debt is >0 and red if <0

=ColorMix1(if(Sum(debt)>=0,0,1),LightBlue(),red())

1 Solution

Accepted Solutions
JonnyPoole
Former Employee
Former Employee

You can use the rangesum(above()) expression in the background color to handle expressions where you are using 'full accumulation'.  You can also use the rangesum(above()) expression in lieu of the sum( field) with full accumulation in the expression formula as well. Your choice.

In the attached example, i used the latter and in the background color.

Let me know if its accumulating and coloring as you want.

Capture.PNG.png

View solution in original post

11 Replies
MK_QSL
MVP
MVP

Presentation Tab

Click on + sign on your expression

Write below in Background color

IF(SUM(debt)>0,Blue(),Red())

JonnyPoole
Former Employee
Former Employee

Is this formula performed on the dimension on the expression ?  For dimensions, you may need to aggregate by date using aggr()

Also consider a simpler formula

if(Sum(debt)>=0,LightBlue(),red())

Not applicable
Author

its performed  on the expression, the colour af background .. but it works strange.. the colour is changed not by passing nul...

Not applicable
Author

Manish, the problem is that i did that way, but it doesnt work correctly=(

MK_QSL
MVP
MVP

Your sample data or sample apps would be helpful to give you correct answer...

JonnyPoole
Former Employee
Former Employee

Are your numbers in the data model cumulative totals ?  Is the expression formula also sum(Sales) or something different ?

Not applicable
Author

Yes, it is cumulative totals  and the expression formula is also sum(debt)

JonnyPoole
Former Employee
Former Employee

You may need to sum up all preceding values as well then


Consider replacing Sum(Debt) with the following that would aggregate all previous values.


rangesum(above(Sum([debt]),0,rowno()))

Not applicable
Author

i didn't really undestand , if i should put it in the expression, or in the backround colour as well?

Anyway, understood thats its not the best way to show debts, bars are more effective.. and though in a bar chart it clear, whats below zero, and whats above, its still interesting to make different colours..

Could you kindly look at my app, please?