Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

JustinDallas
Valued Contributor

Change bar chart color if value is above average.

Hello Folks,

I've got a simple bar chart, with an Average calculation reference line.  Thus far, it looks like this.

BarChart.PNG

What I would like is that when the Bar is above the reference line, it's Blue and when it's below the reference line it's Green

My expression looks like so: 

If( Count(Order) > Avg(Aggr(Count(Order),[Scheduled Week])), Blue(), Green())

But not matter what, the bar is ALWAYS green.  What should I be using to get this to work?  For instance, the value 226 should be Blue as it is above the average and the value of 184 is below the average.

Any help is greatly appreciated.

1 Solution

Accepted Solutions

Re: Change bar chart color if value is above average.

Your bar chart seems to be suffering from an inverse "Lake Wobegon effect" (Lake Wobegon - Wikipedia).


Add a TOTAL keyword.


If( Count(Order) > Avg(TOTAL Aggr(Count(Order),[Scheduled Week])), Blue(), Green())


-Rob

http://masterssummit.com

http://qlikviewcookbook.com

2 Replies

Re: Change bar chart color if value is above average.

Your bar chart seems to be suffering from an inverse "Lake Wobegon effect" (Lake Wobegon - Wikipedia).


Add a TOTAL keyword.


If( Count(Order) > Avg(TOTAL Aggr(Count(Order),[Scheduled Week])), Blue(), Green())


-Rob

http://masterssummit.com

http://qlikviewcookbook.com

rajankasbe91
New Contributor III

Re: Change bar chart color if value is above average.

Hi Justin,

Try Putting your expression in a variable and then try.

Something like this

if( Sum(Sales)  >

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

Regards,

Rajan

Community Browser