Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

albi_prakash
Contributor II

Colors for bars based on Target

Hi All,

I am having a bar chart in qliksense application which needs to show based on target value.

If bar is higher than target then it will be green else red.

This bar chart will have the two set of expression like previous month and previous year.

So I need to show the Bars based on Target value either in Red or Green based on Target on both 'Previous Month' and 'Previous Year' view

The below expression used in "Measure"

Exp 1:

if(v_set_reset=1,sum({<MetricName= {'M1'},Period = {'$(=$(v_previous_month))'}>}vlaue),

(sum({<Level2Name = {'Perfect Index'},Year = {'$(=$(v_previous_year))'}>}Level2vlaue))/12)

The Target expression used in Colors

Exp 2:

(only({<metric_id = {'51'},loc= {'1'}>}boundary),RGB(70,198,70),RGB(249,63,23))

so if Exp 1 > Exp 2 RGB(70,198,70),RGB(249,63,23)

1 Reply
kvanandan1
Contributor

Re: Colors for bars based on Target

Hi ,

In the color expression, please try similar to below expression

=if($(vMeasure)=1, if(Sum(Pmonth)>Sum(Target),green(),red()), if(Sum(Pyear)>Sum(Target),green(),red()))