This week, I got an interesting question about Power BI: “Can I format a specific cell or row in a table or matrix?”
My answer was yes and I thought it could be a great blog.
Let’s say, you need to format the Sales Amount for all countries as a whole number, except for Australia.
Note: The sample data above is only to show how to format a specific cell or row in a table or matrix.
See below two ways you can do it.
Step 1 – Create a calculated column as:
Format = IF ( Sales[Country] = "Australia", "####.00", "###" )
Step 2 – Create a measure as below:
Total Sales = FORMAT ( SUM ( Sales[SalesTax] ), MAX ( Sales[Format] ) )
Create a measure as below:
Total Sales = IF ( MAX ( Sales[Country] ) = "Australia", FORMAT ( SUM ( Sales[SalesTax] ), "####.00" ), FORMAT ( SUM ( Sales[SalesTax] ), "###" ) )
You can use the same example above to apply different formats, such as decimal place, percentage and others. See more information on https://docs.microsoft.com/en-us/dax/format-function-dax
Hope it helps!
2 thoughts on “Power BI: How to format a specific cell or row in a table or matrix?”
How do I format cells in Power Query when I am trying to validate a specific number of cells. The cells can be one of either three ways. They can be formatted in any random numbers with 2 dashes in this specific format (123-1234-12345). They can be formatted in any random 3 letters followed by 5 numbers like so (ABC12345). And the last way can be if it contains the word “Case” but I know how to do that. If the cells do not contain either of these three formats then it is Invalid.