1 Reply Latest reply on May 19, 2017 9:30 AM by Simon Runc

    Dynamic Format of Metric

    Joseph Bertram

      Hi everyone,


      I have a selector that I am allow users switch between three metrics.  One is a decimal, one is an integer and one is a percentage formatted data type.


      I want the formatting of the selector to inheirit the format of the item that is selected via the parameter. 


      I used "automatic" formatting but that didn't do what I wanted it to do.  It basically made everything an integer. 


      Then I tried "Custom" but left the format box blank.  That almost did what I wanted to do, however, the decimal displayed all digits instead of truncating to 4 the way I had specified in the decimal column and the percentage was formatted as a decimal.


      Any idea how to do this?

        • 1. Re: Dynamic Format of Metric
          Simon Runc

          Hi Joseph,


          So this is a bit of a pain in Tableau (one of my only gripes, so can't complain too much!!)...you might like to vote this idea up




          Nice try, btw, with the blank custom...I hadn't thought of trying that (would have been nice if it had worked!)


          So the work around we currently have, is to create a calculation for each type you want, where it only returns the required value else NULL. Now as Tableau don't plot NULL (well it can't...and no one can!!) we can put the 3 calculations together in the label and it only returns the selected one....


          So I created 3 calcs

          [Selector - Decimal]

          CASE [Selector Parameter]

          when 'Decimal' then [Decimal]

          //when 'Percentages' then [Percentages]

          //when 'Integer' then [Integer]



          [Selector - Integer]

          CASE [Selector Parameter]

          //when 'Decimal' then [Decimal]

          //when 'Percentages' then [Percentages]

          when 'Integer' then [Integer]



          [Selector - Percentage]

          CASE [Selector Parameter]

          //when 'Decimal' then [Decimal]

          when 'Percentages' then [Percentages]

          //when 'Integer' then [Integer]



          and set the formatting for each one how we want....


          We can then place them side by side in the label/tooltip...as per the below



          and we get the effect we want.


          Now if you want to use these in a chart, and have the chart axis reflect the required formatting...the only way I know is to sheet swap. Here is a link to an article on this


          Dynamic Axis Labels/Formatting/Tooltips for Measure Selector


          hope that helps, and fingers crossed for the Format function soon!!