How can we improve Power BI?

Conditional formatted measures using SWITCH

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.

2,045 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Matt Allington shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    51 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Sean Cupolo commented  ·   ·  Flag as inappropriate

        Would truly add some flexible functionality. I have a matrix that has multiple measures that are inter-related (QTY, Unit Rate, Hours, Unit Price, etc. Putting them all on a matrix at the same time is confusing for the end user. Adding a slicer to select the measures that the user wants to see makes for a valuable analytic. Using Switch is the only current option. However, a better option would be to just build the functionality into the matrix and slicer essentially building a field filter.

      • Paul Turley commented  ·   ·  Flag as inappropriate

        I've encountered this as well. I klugy work around is to return a formatted string for the measure. Not an ideal solution, I admit.

      • Colin Banfield commented  ·   ·  Flag as inappropriate

        Mixing program logic with presentation logic is not a good idea. Since SWICH is syntax sugar for nested IFs, it is equivalent to adding a number format parameter to an IF statement. SWITCH is not the right place for setting conditional number formats. The correct place is in conditional formatting. At the time of this comment, Excel has had the capability for ten years.

      • Anonymous commented  ·   ·  Flag as inappropriate

        We also need Custom Number format. So that we can use our own number formats just like excel.

      • David Cresp commented  ·   ·  Flag as inappropriate

        It would be great if this could get some more votes. It is a really necessary change that would greatly assist with formatting in visuals. Please support this one so that we can get Microsoft to look at this.

      • Roberto commented  ·   ·  Flag as inappropriate

        I hope that this feature will be available also by using if-then-else. Instead of using format DAX function, I would like that it will be introduced a function to return data with a specific format (integer, floating point with specified format, currency, percentages, etc.).

      • Anonymous commented  ·   ·  Flag as inappropriate

        This would be very useful. I have a visual that shows a bar graph of income by client with two switchable linear values superimposed on the bar graph--one for average billable rate and the other for total hours billed. This issue prevents the data labels on the lines from being properly formatted and really detracts from the chart.

      • David Cresp commented  ·   ·  Flag as inappropriate

        This would be a great feature for a dashboard that I am working on. Lets hope this one gets picked up.

      • Matt Allington commented  ·   ·  Flag as inappropriate

        @Cheries Mewengkang, what you described will render the number as a text string in a table. This is not the same as changing the number format. If you change the number to a text string, you can't use it in charts or any other place that requires numbers (eg calcs)

      Feedback and Knowledge Base

      Ready to get started?

      Try new features of Power BI today by signing up and learn more about our powerful suite of apps.