Forum Discussion

AnnaZ's avatar
AnnaZ
New Member
9 years ago

Dynamically format a measure as $ or %

Hi there,

 

Is there a way we can dynamically format how a measure X is displayed, either in $0.00 or %, depending on the values in another field? I have a separate field called 'Data Type' which I have indicated 'P' for percentage, 'A' for amount etc and I wish for this to control how measure X appears in $0.00 or %.

 

Thanks for your help. 

 

Cheers!

11 Replies

    • Zaytoon's avatar
      Zaytoon
      Frequent Visitor

      thats great, however can u advise if there is a way to do it without tabular editor

  • Hello AnnaZ

     

    Yes you can do that. 

    Once a measure is created, go to the modeling tab.

    Under modeling tab, look for a field "Format". Click on Format and select the type of value you want to use

     

     

    Thanks,

    Himanshu 

    • AnnaZ's avatar
      AnnaZ
      New Member

      Hi Himanshu,

       

      This option will only allow me to choose one or the other. What I was after was to view the measure in both $ and % depending on another field value. Say for example, this other field value was 'P', then this measure X would be displayed in %. And if the other field value was 'A'. then the same measure X would be displayed in $.

       

      Cheers

       

      • deldersveld's avatar
        deldersveld
        Resident Rockstar

        Try creating the measure with either an IF or SWITCH statement based on the value of the other field. You could then use the FORMAT() function to dynamically change the display format.

         

        Something like = SWITCH('table'[other field],"Value A",FORMAT([measure],"Currency"),"Value B",FORMAT([measure],"Percent"))


        Here's more detail on the different options you can supply for the FORMAT() function: https://msdn.microsoft.com/en-us/library/ee634924.aspx. Scroll down and see the options for Number and use either the pre-defined or custom numeric formatting options.

  • lizgemma's avatar
    lizgemma
    Frequent Visitor

    I struggled with this too! I created a measure that choose between two other measures - but essentionally the measure used to pick between the percentage value and the whole number result needed the format to be changed. So if it is less than 1 then it is a percentage and above 1 it is a whole number. This might not be the case for your data but you can just adjust the formula to suit you. Hope this helps. 🙂 

    *note I have selected Format of the measure not the Measure part. This is my Y-Axis value. 

     

    Update: 

     

  • The only way to solve this issue for me is a (very) ugly method. I created two tables, each with the appropriate format and the use the selection and bookmarks panes and show / hide the graphs I want to see by using the slicer. One extra graph in my model, but it works.