5 Replies Latest reply on Sep 19, 2018 4:39 AM by Simon Runc

    How to add two fields (measures) in the same label

    AKLI HAMRAOUI

      Hi,

      I need to display two fields (measures) in the same label.
      Now I have "Mdc Taux Sorte Dld Pts" measure  displayed in the separated column, i want to display it in the same column displaying the percentage and the shape.

       


      tab.png

       

      When I add the second measure in the label, nothing is diplayed.

       

       

      Any  idea ?

      Thanks in advance

      AH

        • 1. Re: How to add two fields (measures) in the same label
          Simon Runc

          hi Akli,

           

          So I think this is just because Tableau can't fit them in the space, and the 2 values are one under another and there is only space for one row (this is the default way Tableau creates the label, when we add 2 fields). If you go into the label, and put the 2 values in the same row they should appear

           

          • 2. Re: How to add two fields (measures) in the same label
            AKLI HAMRAOUI

            Hi Simon,

            Thanks it works, I have juste a format issue.

            I want to display the values without a shift when the value is -1 (negatif) or when the percentage is 100.0%.

            Any idea?

            shift.png
            Thanks in advance

            • 3. Re: How to add two fields (measures) in the same label
              Simon Runc

              So you can do this via the custom formatting option

               

               

              This takes the form

               

              Format for Positives; Format for Negatives; Format for Zero

               

              so for example

               

              +#,##0.0;-#,##0.0;-#,##0.0

               

              Would show positive numbers with a "+" infront, negative with a "- "in front, and zero with nothing in front (all to 1 DP and Thousand Separated)

               

              You can play with these to get it to display how you need.

              • 4. Re: How to add two fields (measures) in the same label
                AKLI HAMRAOUI

                Hi Simon,

                I need to the same total length for the value with one digit after the decimal.

                Exemple : 100.0% is the maximum length (the max is : 3digits,1digit%) and for 9,2% I need to display : space space9,2%
                How can I format this in order to get :
                100,0% and space space9.2% (_ _ means 2 space)
                for 82.9% I need to display : space82.9% (space char is the empty char or a space in the keyboard) Any help on that.

                 

                 

                Thanks in advance

                • 5. Re: How to add two fields (measures) in the same label
                  Simon Runc

                  So this one is a bit tricky! and will only work with uniform width fonts (such as Courier New, as I've used here)

                   

                  First I need to compute my calculation....I've gone with Share of Sales

                   

                  Next I need to ensure it only returns 1 DP (once I've also de-percentaged it by multiplying by 100)

                   

                  [Sales Share (Rounded)]

                  ROUND(

                  (SUM([Sales]) / TOTAL(SUM([Sales])))*100,1)

                   

                  Next I can count the characters

                  [Sales Share % (Rounded) Char Len]

                  LEN(STR([Sales Share (Rounded)]))

                   

                  Then I can asses how many leading zeros I need

                  [Sales Share % Leading Spaces]

                  IF 4-[Sales Share % (Rounded) Char Len] = 1 THEN SPACE(1)

                  ELSEIF 4-[Sales Share % (Rounded) Char Len] = 2 THEN SPACE(2)

                  ELSE ''

                  END

                   

                  I can then put these all on the text tile

                   

                   

                  And then my pipe separators all line up. Most fonts aren't uniform width...so a '0' isn't the same width as a space, say...which is where this breaks down.

                   

                  Hope that helps and makes a bit of sense.