In Power BI, I am trying to do a custom number format for certain values in a column depending on the text value of another column. Here's an example:
Type Miles (Raw Data) Miles (Desired Format)
PerMile 22.7 22.7
PerMile 26.3 26.3
Total 331.424 331
PerMile 19 19.0
Total 406.782 407
Essentially, if the type is "PerMile", I would like to have it formatted as a decimal number. If the type is "Total", then I would like it formatted as a whole number. I would guess that there is a fairly simple solution, but I can't seem to figure it out.
You can't do variable formatting on a column itself but you can write a measure that returns text formatted how you'd like.
Something roughly like this:
SumMiles =
IF ( SELECTEDVALUE ( Table1[Type] ) = "Total",
FORMAT ( SUM ( Table1[Miles] ), "0" ),
FORMAT ( SUM ( Table1[Miles] ), "0.0" )
)