Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
scabral
Helper IV
Helper IV

Custom Formatted Measure in Pie Chart

I created the following measure to custom format a value:

 

VAR SkipThousands =        
            IF([TIV] > 0, ROUNDDOWN ( DIVIDE ( LOG10 ( [TIV]), 3 ), 0 ))
VAR ValueFormatString =
        SWITCH (
            SkipThousands,
            0, "$#,0",        -- Integer number
            1, "$#,0,.0K",   -- Thousand
            2, "$#,0,,.0M",  -- Million
            3, "$#,0,,,.0bn", -- Billion
            "$#,0,,,,.0T"    -- Trillion
        )
RETURN
IF([TIV] = 0, "$0",
FORMAT([TIV],ValueFormatString))
 
This measure works fine in a table, but if I try to use it in a Pie Chart, i get the following error:
 
Can't Display Visual
Negative vlaues aren't supported and are being displayed as absolute values.
 
There are no negative numbers in the entire dataset for this measure.  If I use just the underlying [TIV] measure, it works fine.  It doesn't like the formatting for some reason.  Is this a bug?
 
Scott
4 REPLIES 4
v-tangjie-msft
Community Support
Community Support

Hi @scabral ,

 

Have you tried going into the dataview and check if there are actuall negative values?

My tests did not reproduce your problem,can you provide some sample data or .PBIX files so that I can better help you solve the problem, please pay attention to protect your private data ,thank you.

 

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Hi Neeko Tang,

 

how to i upload a pbix file to the forum?  I didn't see an option.

Hi @scabral ,

 

Please refer to this link: How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

https://app.box.com/s/csahwld2tyuaiq78u1tysero3u9htdce 

 

Hi Neeko Tang,

 

I've uploaded and shared sample file to BOX and attached link.

 

There is just 1 table where I created a TIV measure to just sum up the Total Insured Value.

 

Now, I noticed that if i create the new measure called TIV Formatted with the code i listed above, it saves it as a text field and i cannot change it.  If I use the attached pbix as the dataset and connect to it via another pbix and create the TIV formatted measure there, it allows me to set it to a number.  Not sure why that is.  But you cannot use text field in the values section of a pie chart, so you will have to use the attached pbix as a dataset and create another pbix to create the measure as a number and use it in the pie chart where you will see the error.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors