Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Bar graph expression multiple conditions and outcomes?

I have a stacked bar graph with, 1 dimension, 1 expression. There are 3 components of the dimension, and based on 3 variables, I want to alter the color of the corresponding components. I started writing this example nested if statement into the Background Color of my single expression which is a simple Sum(Amount):

IF( vComponent1Switch = 1, Sum({< DimensionName={'Component1'}>}Amount) = Green(),

IF(vComponent2Switch = 1, Sum({< DimensionName={'Component2'}>}Amount) = Yellow(),

IF(vComponent3Switch = 1, Sum({< DimensionName={'Component3'}>}Amount) = Red()

This is the general idea, however the logic flow only allows one of these to take affect. If I want Components 1 and 3 to both colorize, only 1 will take affect. What can I substitute in place of the nested if to allow any combination of colors to be altered to the graph, and not just one?

If I have all three switches on, currently the graph only shows the Green change, since it reaches the end of the if statement. I would like all three colors or any combination of colors to display.

Thanks.

2 Replies
sunny_talwar

How about this:

Pick(Match(vComponent1Switch & '|' & vComponent2Switch & '|' & vComponent3Switch, '1||', '|1|, '||1', '11|', '1|1', '|11', '111'),

If(DimensionName = 'Component1', Green()),

If(DimensionName = 'Component2', Yellow()),

If(DimensionName = 'Component3', Red()),

If(DimensionName = 'Component1', Green(), If(DimensionName = 'Component2', Yellow())),

If(DimensionName = 'Component1', Green(), If(DimensionName = 'Component3', Red())),

If(DimensionName = 'Component2', Yellow(), If(DimensionName = 'Component2', Red())),

If(DimensionName = 'Component1', Green(), If(DimensionName = 'Component2', Yellow(), Red())))

Anil_Babu_Samineni

Try like below

1) IF( Dimensionality() = 1, $(vComponent1Switch) = 1, Sum({< DimensionName={'Component1'}>}Amount), RGB(255,255,0),

2) IF( Dimensionality() = 2, $(vComponent2Switch) = 1, Sum({< DimensionName={'Component2'}>}Amount),

RGB(255,255,0),

3) IF( Dimensionality() = 3, $(vComponent3Switch) = 1, Sum({< DimensionName={'Component3'}>}Amount),

RGB(255,255,0))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful