3 Replies Latest reply: Nov 29, 2015 5:21 AM by Hirish V RSS

    Change Color in a bar chart with dinamic expression

    Pasquale Cosimato

      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

        • Re: Change Color in a bar chart with dinamic expression
          Arthur Molino

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

          Capturar.PNG

          Capturar2.PNG

            • Re: Change Color in a bar chart with dinamic expression
              Andrew Walker

              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

            • Re: Change Color in a bar chart with dinamic expression
              Hirish V

              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