Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Conditional colour on bar per customer

I am trying to create a horizontal bar chart showing green if the number is positive and red if it is negative using this expression:

if

(num(

  Sum ({$<[Ar Transaction Trn Year]={$(=Max([Ar Transaction Trn Year]))},

  [Ar Transaction Invoice Date] ={"<$(=addyears(max ({$<[Ar Transaction Trn Year]={$(=Max([Ar Transaction Trn Year]))}>}[Ar Transaction Invoice Date])))"} >} [Ar Transaction Net Sales Value])

,'£###,###,###.')

-

num(

  Sum ({$<[Ar Transaction Trn Year]={$(=Max([Ar Transaction Trn Year])-1)},

  [Ar Transaction Invoice Date] ={"<$(=addyears(max ({$<[Ar Transaction Trn Year]={$(=Max([Ar Transaction Trn Year]))}>}[Ar Transaction Invoice Date]),-1))"} >} [Ar Transaction Net Sales Value])

,'£###,###,###.')

> 0, RGB(102,204,102), RGB(255,0,0))

Currently this performs  the calculation using the complete customer base so I only see green because the overall quantity returned is positive. I want it to show green if positive and red if negative for each customer e.g:

Customer 1 = 100 = Green

Customer 2 = -50 = Red

I know it is possible because but I don't know whether I need to use aggregation in the calculation to achieve it or if there is a simpler way that I am missing.

Any help will be greatly appreciated.

10 Replies
Anonymous
Not applicable
Author

Wow it was as easy as just changing the background text setting on the expression. I was trying to make it much more complicated. Thanks guys for your help.