Matt Allington on 16 Jul 2016 04:20:35
A current limitation in Power BI SWITCH measures (and all Power Pivot actually) is that a SWITCH measure must have a single format. It is currently not possible to conditionally format the measure result based on any criteria - it is one single format only. There are valid use cases where you may want to change the format of the SWITCH measure depending on the result. Consider the following SWITCH statement
myMeasure = SUMX(MeasureTable,switch([selected measure],
1,[Total Sales],
2,[Total Cost],
3,[Total Margin],
4,[Chg Sales vs LY %]
))
The first 3 results are all currency format, but the last result is a percentage format. This currently can't be controlled. I would like to see an optional 3rd parameter in the SWITCH statement to set an alternate number format.
Administrator on 20 Aug 2020 01:22:10
From the comments and scenarios everyone's describing, the problem is really that you need a way to allow end-users to change which measure is displayed in a visual on the fly. As a few folks have mentioned, the FORMAT function might help in the interim, as long as you're showing the results in text rather than a chart. https://docs.microsoft.com/en-us/dax/format-function-dax has details on how to use that. The expression-based formatting feature that we've started work on may help to a certain extent, but that's really designed to change a visual's properties rather than the data type or format. We'll look into extending that work to support this scenario as well. We're moving this to Backlog status - our core plan is to build ways that end-users can change the dimensions or measures that are visible in a chart on the fly. They'll be able to explore much more freely rather than relying on the author to have set up complex expressions to control what's available. We'll update with more details as they're available.
- Comments (70)
RE: Conditional formatted measures using SWITCH
RE: Conditional formatted measures using SWITCH
RE: Conditional formatted measures using SWITCH
Hi - this can now be done although it is a bit complex and has some limits.
Check my post here:
https://community.powerbi.com/t5/Desktop/Dynamic-formatting-of-measures-tutorial/m-p/1297373#M565099
RE: Conditional formatted measures using SWITCH
needed thanks
RE: Conditional formatted measures using SWITCH
We need this feature in financial reports! Users have to be able to switch to actual values and values in thousands.
RE: Conditional formatted measures using SWITCH
In Excel, you can change the format of a y-axis on a graph or the values of a pivot table value independently of the underlying source data. So similarly to being able to adjust the Display Units and decimal places of the labels and/or axis of a given visual you should also be able to edit the format independent of the underlying measure or column. Further to address this idea, you could allow expressions on this similar to titles which would solve the problem that we are having.
This would allow the underlying measure or column to remain as a number as opposed to text and therefore it would be "graphable" and then the graph or visual axis/label formatting could handle how it is displayed in terms of the format.
Update: looks like they are solving this with calculation groups, but i still like the idea above which would be an agile option for end users.
RE: Conditional formatted measures using SWITCH
myMeasure = SUMX(MeasureTable,switch([selected measure],
1,{[Total Sales], type currency},
2,{[Total Cost], type currency},
3,{[Total Margin], Percentage.Type},
4,{[Chg Sales vs LY %], Percentage.Type}
))
RE: Conditional formatted measures using SWITCH
Please implement this idea. Would make our financial reporting much easier.
RE: Conditional formatted measures using SWITCH
My view is that this would be solved if the FORMAT function had Left, Center and Right alignment and padding. Maybe this would be simpler?
RE: Conditional formatted measures using SWITCH
Still waiting for this to be implemented, this is a bummer for people who have to create financial reports that have different measures with different data types when using slicer measures