Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
pascos88
Creator II
Creator II

Change Color in a bar chart with dinamic expression

I have a bar chart that change expression dinamically.

This is the espression that I have in a chart.

=(if(vView='MWh' and vTime='Month', Only (MonthProd), if(vView='MWh' and vTime='Year',Only(YearProd),

if(vView='Revenue' and vTime='Month', Only (MonthRevenue), if(vView='Revenue' and vTime='Year',Only(YearRevenue),

if(vView='Opex' and vTime='Month', Only (MonthOpex), if(vView='Opex' and vTime='Year',Only(YearOpex))))))))

the Dimension is always the same (Legal entity).

I would like to have a different color that depends from the size of my dimension.

Id Value od dimension is <0 so the color of the bar that are <0 should be red otherwise green.

The problem is that I don't know witch Expression will be call becouse it depends from the variable.

Thanks for help

Pasquale

3 Replies
arthur_dom
Creator III
Creator III

You can give you expression a Name and use it on the color expression:

Capturar.PNG

Capturar2.PNG

effinty2112
Master
Master

Hi Arthur,

My reply is not in response to your question, instead it is to offer what I hope is a useful tip. Your expression has a large nested if statement. These are horrible to read and awful to edit. If you instead use the QlikView functions Pick and Match you can replace this with an expression that you may find is easier to read and to edit:

Pick(Match(vView & vTime,

'MWhMonth',

'MWhYear',

'RevenueMonth',

'RevenueYear',

'OpexMonth',

'OpexYear'),

Only(MonthProd), //MWhMonth

Only(YearProd), //MWhYear

Only (MonthRevenue), //RevenueMonth

Only(YearRevenue), //RevenueYear

Only (MonthOpex), //OpexMonth

Only(YearOpex)) //OpexYear

HirisH_V7
Master
Master

Hi,


Does you want to show colors for the two different ranges

For eg:-

In (0-100)

for 0-40 yellow()

for 40-60 Green()

for 60-100 Red()

In (100-200)

for 110-140 yellow()

for 140-160 Green()

for 160-200 Red()

Is this your requirement or simple color ??

You can use this for simple color -

For Dimension:-

In backGround COlor

If(Field='A',Red(),Green())

Similarly

For Expression:-

In backGround COlor

If(Value<=100,Red(),Green())



Hope this Helps else post a sample App if Possible,

Regards,

HirisH

HirisH
“Aspire to Inspire before we Expire!”