Forum Discussion
Dynamically format a measure as $ or %
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
- AnnaZ9 years agoNew 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
- deldersveld9 years agoResident 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.- AnnaZ9 years agoNew Member
I used the switch function as below but the new measure is now formatted as a text and cannot be added to the visual.
CurrentValueFormatted = switch([DataTypeMeasure],"P",format([CurrentPercentValue],"Percentage"),"A",format(HotelKPICalculation[CurrentPercentValue],"Currency"))