5 Replies Latest reply on Jan 3, 2019 11:34 AM by Paul Wachtler

    Legend Calculation

    Naryb sarah

      Hi

       

      i would like to show the comparison of quantity with the Technology and Furniture.

       

      Issue: if Technology sales greater than Furniture then it supposed to be Green Else Red.

       

      My Trial Logic:              IF COUNT(IF [Category] = 'Furniture' THEN [Quantity] END) <=

                                              COUNT(IF [Category] = 'Technology' THEN [Quantity] END) THEN 1 ELSE 0 END

       

      But i am unable to achieve the same.

       

      Can some one please help me on this logic.

       

      Thanks in advance.

       

        • 1. Re: Legend Calculation
          Paul Wachtler

          Hi Naryb,

           

          You can accomplish this with an LOD expression.  Right now the level of detail of your viz is at the State and Category level - each category can never be the other which is why your current calculation isn't working.  We can get it working with an LOD though like this:

           

          IF

          {FIXED [State]: sum(IF [Category] = 'Furniture' THEN [Quantity] END)}

          <=

          {FIXED [State]: sum(IF [Category] = 'Technology' THEN [Quantity] END)}

          THEN 1 ELSE 0

          END

           

          Best,

          Paul

          • 2. Re: Legend Calculation
            Naryb sarah

            Hi Paul,

             

            Thank you for your reply but it didn't workout.

             

            Please check as below mentioned.

             

             

             

            Thank you

            • 3. Re: Legend Calculation
              Paul Wachtler

              That looks like it's working as you described it.  If Technology sales are higher the bars are one color and if Furniture is higher than it's another - you can change these two colors to whatever you'd like.

               

              Do you mean that you only want the technology bar to be colored?  In that case, you can do this:

               

              IF [Category] = "Technology" then

                   IF {FIXED [State]: sum(IF [Category] = 'Furniture' THEN [Quantity] END)}

                   <=

                   {FIXED [State]: sum(IF [Category] = 'Technology' THEN [Quantity] END)}

                   THEN "Green" else "Red"

                   END

              else "Blue"

              end

               

              Also, as a tip, putting red and green on the same chart isn't recommended since color blind people tend to be unable to see the difference.  Blue and Orange is preferable (and you can use grey for the non-colored bars).

              • 4. Re: Legend Calculation
                Naryb sarah

                Hi Paul,

                 

                Really appreciate your time and help.

                 

                Happy New year Paul.

                 

                Thank you

                • 5. Re: Legend Calculation
                  Paul Wachtler

                  You're welcome Naryb, happy to help!  Happy New Year to you too!