Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gfisch13
Creator II
Creator II

Change the color of a Bar based on an expression

Hi Everyone, I'm traying to change the color of a bar in a bar chart to RED Based on this expression but I keep getting the 'error in expression' message.   Can anyone tell me what I'm doing wrong? 

Thanks! 

George

= (Sum (AMOUNT_AT_RISK_USD) - Sum (AMOUNT_PREVENTED_USD) - Sum (AMOUNT_RECOVERED_USD))>0, RED())

1 Solution

Accepted Solutions
sunny_talwar

Assign a single color to each of the expression. Like for Loss you can try adding RGB(192,192,192) within the background color. You don't need any if statements here.

View solution in original post

21 Replies
sunny_talwar

I think you missed the If Statement at the beginning (also made some other changes):

=If(RangeSum(

Sum(AMOUNT_AT_RISK_USD),

-Sum(AMOUNT_PREVENTED_USD),

-Sum(AMOUNT_RECOVERED_USD)) > 0, RED())

gfisch13
Creator II
Creator II
Author

Hi Sunny T - Unfortunately this did not work, and I'm wondering if I'm presenting it properly.  Each of those amounts are fields in my table.  I've now calculated the Loss and made that a field in my table as well.

Each of these fields will be calculated as a sum in my dimension.  Using the LOSS as my example I still want that bar to be red but none of the options I try seem to work.  I just tried changing the background color in the expression tab which I thought was easy, but that didn't work.  I'm confused.  What is the simplest way to accomplish this?

sunny_talwar

I am not sure I understand your setting completely. Would you be able to provide a sample to show what isn't working?

gfisch13
Creator II
Creator II
Author

This is a screen grab of my expressions.  Each of those expressions represent a different piece of a bar graph that is totaling these by country.   I want each of these to have the color I specify and not the color that Qlikview assigned.  Hope this helps!!  Thanks!BarColors.JPG

sunny_talwar

Assign a single color to each of the expression. Like for Loss you can try adding RGB(192,192,192) within the background color. You don't need any if statements here.

gfisch13
Creator II
Creator II
Author

Ah, now I got it.  Never used the RGB format!!  Thanks for your help!!!!!!

sunny_talwar

You don't have to use RGB(), but that was an example. Red() or Blue() should work as well, but RGB() just give you more options.

gfisch13
Creator II
Creator II
Author

I tried both so that I'd understand how to use those functions.  I like RGB more because of the differences in colors.

Thanks for your help!

sunny_talwar

No problem at all

Best,

Sunny