Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Change the Color of Bar depending Upon a condition not on Value

I have a bar chart in which X-axis represent 12 months & on Y-Axis it is Showing Sum(Sales).I have made a

Reference Line by making use of --(Sum(Sales)/(Count(DISTINCT(month))))----Avererage Value.

I want to change the color of Bar in Bar chart depending upon the following condition:-

if(sum(Sales) >(Sum(Sales)/(Count(DISTINCT(month)))),Blue(),Red())

but it is not working...!

If i but a vlaue in place of Average Calculation then i am getting my Result.

if(sum(Sales) >65,Blue(),Red())

Find the attached Sample Qvd for this Problem.

16 Replies
its_anandrjs

Hi,

It is not hard coded the formula in variable

vAvg =(Sum(Sales)/(Count(DISTINCT(month))))

is updated according to the values that are changes in your columns.

Let me know about this.

HTH

Regards,

Anand

Not applicable
Author

Ya Anand I got that it is not hard coded but i have tried this Variable concept also but it is also not working for me

its_anandrjs

When writing the formula in variable write some like

Variable name vAvg and in definition write

=(Sum(Sales)/(Count(DISTINCT(month)))) with equal sign.

and use this variable in in Background properties

if( Sum(Sales)  >

    $(vAvg),Blue( ),Green( ) )

Regards,

Anand


Not applicable
Author

Finally i got it   .

Thanks Anand Chauhan for helping me out.

I want to know one thing more that what is the use of = operator Exactly out in it.

its_anandrjs

When ever you create any variable and the variable gets value from any formula if you not put = sign before formula like

(Sum(Sales)/(Count(DISTINCT(month))))

it will treat like a text script and but if you put

=(Sum(Sales)/(Count(DISTINCT(month))))  = before that so by this the value of formula is assign to the variable and variable holds the value of formula that is the difference.

Regards,

Anand



Not applicable
Author

Now i have a complete Picture of it.

Thanks Anand.Can you provide me your personal e-mail id .So i can remain in your touch always

its_anandrjs

I am available every time in the Qlikview Community and if you want to ask a question then send directly a Private Discussion to me so i respond to you on your questions.

Regards,

Anand