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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.