Dynamic format using DAX

Just a quick blog post today. Someone had a scenario where they wanted to have a different number of decimal points based on the items on the rows. Initially they wanted to go with a calculated column but it is much easier to do this using the FORMAT function in DAX. Using the FORMAT function you can return the numerical value any way you want it.

Let’s take the following example. I have the several different devices and I want to format them all differently. I can write a single measure that return different formatting for each device.

You can also use this to show different symbols as you would use this when doing currency conversion.

One thing to observe here is that thanks to several performance optimizations the use of IF and SWITCH in Power BI desktop is significantly improved as compared to Power Pivot for Excel 2013 and SQL 2014.

This entry passed through the Full-Text RSS service – if this is your content and you’re reading it on someone else’s site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.