cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rymatt830
Helper I
Helper I

Change Measure Format

I am unable to change the format of a measure. The Formatting section of the Modeling tab only allows Format: Text to be selected. Here's the measure:

NHSSVUNNetAssets = CALCULATE(MEDIAN(AuditNumbers[UnrestNA]),AuditNumbers[PCODE]="8217")

 

Capture.PNG

It's possible I am using the wrong DAX. For example, Median is not necessary because the measure filters to one value; however, the measure requires an aggregation. I want the measure displayed as currency. Any help would be great.

1 ACCEPTED SOLUTION
Twan
Advocate IV
Advocate IV

That is very strange.  It looks like is a bug with the MEDIAN() function.  If you change your measure to use AVERAGE() instead of MEDIAN() it allows you to format the measure in formats besides Text.

 

One way to get around this bug would be to calculate the median without using the MEDIAN() function.  SQL BI has a great desctiption of how you would write your own MEDIAN measure in DAX.

 

It would look like this for your model:

Custom Median :=
(
    MINX (
        FILTER (
            VALUES ( AuditNumbers[UnrestNA] ),
            CALCULATE (
                COUNT ( AuditNumbers[UnrestNA] ),
                AuditNumbers[UnrestNA]
                    <= EARLIER ( AuditNumbers[UnrestNA] )
            )
                > COUNT ( AuditNumbers[UnrestNA] ) / 2
        ),
        AuditNumbers[UnrestNA]
    )
        + MINX (
            FILTER (
                VALUES ( AuditNumbers[UnrestNA] ),
                CALCULATE (
                    COUNT ( AuditNumbers[UnrestNA] ),
                    AuditNumbers[UnrestNA]
                        <= EARLIER ( AuditNumbers[UnrestNA] )
                )
                    > ( COUNT ( AuditNumbers[UnrestNA] ) - 1 ) / 2
            ),
            AuditNumbers[UnrestNA]
        )
) / 2

Then change your measure to use the custom median measure and you will be able to change the format of this measure to currency.

NHSSVUNNetAssets = CALCULATE([Custom Median] ,AuditNumbers[PCODE]="8217")

 

View solution in original post

6 REPLIES 6
mbdtz
Advocate III
Advocate III

I found a fix to this was to just put a vlue around the outside 🙂

 

NHSSVUNNetAssets = Value(CALCULATE(MEDIAN(AuditNumbers[UnrestNA]),AuditNumbers[PCODE]="8217"))

 

Anonymous
Not applicable

Why is this marked "Solved?" There is still a bug in Median aggregation which prevents numbers from being formatted as anything other than text. 

The bug is still there

Greg_Deckler
Super User
Super User

Try SUM or MAX instead of MEDIAN


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition
Twan
Advocate IV
Advocate IV

That is very strange.  It looks like is a bug with the MEDIAN() function.  If you change your measure to use AVERAGE() instead of MEDIAN() it allows you to format the measure in formats besides Text.

 

One way to get around this bug would be to calculate the median without using the MEDIAN() function.  SQL BI has a great desctiption of how you would write your own MEDIAN measure in DAX.

 

It would look like this for your model:

Custom Median :=
(
    MINX (
        FILTER (
            VALUES ( AuditNumbers[UnrestNA] ),
            CALCULATE (
                COUNT ( AuditNumbers[UnrestNA] ),
                AuditNumbers[UnrestNA]
                    <= EARLIER ( AuditNumbers[UnrestNA] )
            )
                > COUNT ( AuditNumbers[UnrestNA] ) / 2
        ),
        AuditNumbers[UnrestNA]
    )
        + MINX (
            FILTER (
                VALUES ( AuditNumbers[UnrestNA] ),
                CALCULATE (
                    COUNT ( AuditNumbers[UnrestNA] ),
                    AuditNumbers[UnrestNA]
                        <= EARLIER ( AuditNumbers[UnrestNA] )
                )
                    > ( COUNT ( AuditNumbers[UnrestNA] ) - 1 ) / 2
            ),
            AuditNumbers[UnrestNA]
        )
) / 2

Then change your measure to use the custom median measure and you will be able to change the format of this measure to currency.

NHSSVUNNetAssets = CALCULATE([Custom Median] ,AuditNumbers[PCODE]="8217")

 

Thank you for your help, Twan. Using AVERAGE() instead of MEDIAN() allows the format to be changed. Also, thank you for including a reference to the custom function.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

Power BI Dev Camp Session 25 with aka link 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, August 25 at 11a PDT for a great session with Ted Pattison!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors