6 Replies Latest reply on Feb 26, 2018 9:08 AM by Priyesh Singh

    Colouring Multiple measures

    Priyesh Singh

      Hi Team,


      I have stuck in a scenario where i have to colour  different measures based upon a condition .

      The problem statement in my scenario is I have to write a calculation that if cr1time is greater than 20% of Total time then it should be blue or any colour.

      Similarly If cr2 is greater than 20% of Total Time then it should be any colour and so on till cr24.


      I have attached the twbx file.




      Thanks In Advanced.

        • 1. Re: Colouring Multiple measures
          Norbert Maijoor

          Hi Priyes,


          Please evaluate the option of "Use Separate Legends" explained here




          1 of 1 people found this helpful
          • 2. Re: Colouring Multiple measures
            nikher verma

            Hi Priyesh ,


            Mainly you were facing two issues while doing so -


            1.While writing the calculation as one of your field is aggregated and another one is non aggregated .

            try solving it with this ::

            Error "Cannot mix aggregate and non-aggregate arguments with this function" When Creating a Calculated Field | Tableau S…


            2. Once you have solved the 1st problem ;all your fields are under one legends so use separate legends for each field .





            • 3. Re: Colouring Multiple measures
              Glenn Kuly

              Hi Priyesh, the way your view is constructed (with each CR time set up as a separate calculated field for each location vs locations as columns ), you are going to have a brutal time color coding each of these measures separately.


              To do so, you're going to have to set up a dummy column for each measure, and create a calculated field for each column to do the color coding.


              Here's one approach -- I've only included CR1 Time in ths view:


              color codeing.png


              You can see how the dummy columns are created -- min(0) -- with measures inserted as text in the marks card.


              To do the color coding, i did a series of 3 calculated fields here, but they can be combined into one or two:


                  CR1 Time Total: TOTAL([Cr1 Time])


                  CR1 Time Total 20%:    TOTAL([Cr1 Time]) * .2


                  Cr1 Time > 20% of Total: [Cr1 Time] > [Cr1 Time Total 20%]


              This last field is used on the color shelf.


              I've attached a workbook (v10.5).


              FYI not sure if this is me (i.e. my laptop), but i'm finding your workbook to be brutally slow to work with. For views involving many many calculated fields, I've found it a good practice to do everything i can to move calculated fields in Tableau back to my analytical file (i.e. create CR time and frequency values for each location during data prep).


              -- Glenn

              • 4. Re: Colouring Multiple measures
                Glenn Kuly

                Here's what i mean by a simpler view with location as columns and CR time as a single measure:


                color coding 2.png


                Now if you can come up with a single calculated field indicating that CR Time in a given cell is greater than total CR time for the corresponding column, you can color code the columns separately and in one step as per Norbert's post.


                The color coding calculated field won't be simple, it will have to involve a LOD expression fixed on location. I'll give this a try later on time permitting.


                -- Glenn

                • 5. Re: Colouring Multiple measures
                  Glenn Kuly

                  ...maybe not so difficult after all.


                  The color coding field for CR time as a single measure used in the attached workbook (v10.5) is:


                      Crstim > 20% of total: SUM([Crstim]) > (TOTAL(SUM([Crstim])) * .2)


                  Drop this on the color shelf, and then click on the pill arrow to select Edit Table Calculation.


                  color coding 3.png


                  To color code each column separately, apply the calculation by specific dimensions (location and reason), restarting every location.


                  I don't know if this view meets your requirements, but it is significantly easier to set up compared the approach i show above.


                  -- Glenn

                  1 of 1 people found this helpful
                  • 6. Re: Colouring Multiple measures
                    Priyesh Singh

                    Thanks You Glenn


                    This is what exactly I am looking.Nice Approach....




                    Thanks all for your help.