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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
ZhangKun
Super User
Super User

Custom number format strings

In the documentation for custom numeric format strings:

ZhangKun_0-1735489310956.png

However, in actual testing, it was found that the following expression would produce an unexpected result:

 

// 0%
Number.ToText(0.4, "0;-0;0%")

// 0.4
Number.ToText(0.4, "0.0;-0;0%")

 

So, is this a bug?

1 ACCEPTED SOLUTION

Sorry, missed that and learned something.

What do you expect for output given those format strings.

 

The second one appears correct. What would you expect for your first format string?

 

The behavior you see is documented in the link you provided:

 

If the number to be formatted is nonzero, but becomes zero after rounding according to the format in the first or second section, the resulting zero is formatted according to the third section.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Your results look correct to me as well. in the first case you were saying if it's positive, make it a whole number, which rounds down to zero, and since your third argument says if zero make a percent, you, get 0%. in your second example you say if the number is positive make it one decimal therefore you get 0.4 which does not equal zero and therefore does not become a percent.

 

--Nate

ronrsnfld
Super User
Super User

deleted as incorrect

Sorry, missed that and learned something.

What do you expect for output given those format strings.

 

The second one appears correct. What would you expect for your first format string?

 

The behavior you see is documented in the link you provided:

 

If the number to be formatted is nonzero, but becomes zero after rounding according to the format in the first or second section, the resulting zero is formatted according to the third section.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.