2 Replies Latest reply: Jun 28, 2016 12:40 PM by Anil Samineni RSS

    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.



        • Re: Bar graph expression multiple conditions and outcomes?
          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())))

          • Re: Bar graph expression multiple conditions and outcomes?
            Anil 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),


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