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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Need Help in number formating by using DAX commands

Hi ALL,
I need some help in number formatting in DAX , Below is the scenario & the DAX function which I have written.

I have revenue field in my source and as Power Bi represents Billion as "bn" and my client wants it to represent it as "B" , so they want if the numbers are less than 1000 then it represent at $ , if it is less than 1000000 then it should represent as $K , if it less than 1000000000 then it should be representing as $M and anything greater than that would be termed as $B. 

Here is what i have written :
"$"&
VAR number_ =
MAX ([Total Revenue] )
VAR decimal = "0.0"
RETURN
IF (
number_ >= 1000000000,
FORMAT ( number_ / 1000000000, decimal & "B" ),
IF ( number_ >= 1000000, FORMAT (number_ / 1000000, decimal & "M" ) )
).
when I create a new column and write a above dax function it is treating as Text and i am not able to summarize it , 
if I create a new measure then I input the above DAX function then it is not even allowing me to change the format from Text to Decimal.
Kindly Please help!!
Thanks & Regards
Shiv

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, by my test, a calculated column can't get the correct total anyway, but a measure can, because measure can first get the total number then format it.

I create a sample.

vkalyjmsft_0-1654073486755.png

Here's my solution, create a measure, use SUM in the formula, not MAX.

Measure =
VAR number_ =
    SUM ( [Total Revenue] )
VAR decimal = "0.000"
RETURN
    IF (
        number_ >= 1000000000,
        FORMAT ( number_ / 1000000000, decimal & "B" ),
        IF ( number_ >= 1000000, FORMAT ( number_ / 1000000, decimal & "M" ) )
    )

 Get the correct result. In order for measure to get multiple values, additional columns are required in the visual.

vkalyjmsft_1-1654073729958.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, by my test, a calculated column can't get the correct total anyway, but a measure can, because measure can first get the total number then format it.

I create a sample.

vkalyjmsft_0-1654073486755.png

Here's my solution, create a measure, use SUM in the formula, not MAX.

Measure =
VAR number_ =
    SUM ( [Total Revenue] )
VAR decimal = "0.000"
RETURN
    IF (
        number_ >= 1000000000,
        FORMAT ( number_ / 1000000000, decimal & "B" ),
        IF ( number_ >= 1000000, FORMAT ( number_ / 1000000, decimal & "M" ) )
    )

 Get the correct result. In order for measure to get multiple values, additional columns are required in the visual.

vkalyjmsft_1-1654073729958.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Whitewater100
Solution Sage
Solution Sage

Hi:

If you new to format text to number. In DAX usually INT or VALUES function can helpful. I think you can use a SWITCH statement. I did a little reseach on how to Format like you mentioned and found the following:

 

To Format to $1.56B

Measure = format(1558753918,"$#,,,.##B")  the number can be substituted for your measure. I have other examples below.  I hope this helps!

Whitewater100_0-1653786647031.png

 

 

 

"Currency (2)", FORMAT (             1234.567, """US$"" #,0.00" )

Currency (2)

US$ 1,234.57

 

Millions:

Sales to (M) = FORMAT([Sales Amount], "#,##,,.0M")     = 2,715.3M

Sales to (M) = FORMAT([Sales Amount], "#,##,,M")    =2,715M

 

Europe:

FORMAT(MuMeasure[EU], "#,##,,.0M") 

 

Thousands

 

Sales to (K) = FORMAT([Sales Amount], "#,##,K")   =205K

 

Sales to (K) = FORMAT([Sales Amount], "#,##,.0K") put it to one decimal   294.8k vs 294801

Whitewater100
Solution Sage
Solution Sage

Hi:

You can format :

To Format to $1.56B

Measure = format(1558753918,"$#,,,.##B")    * place measure instead of 1558753918.

 

amitchandak
Super User
Super User

@Anonymous , first create a measure and do that formatting there. It will text measure but will work

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,
I have followed the way you mentioned but when i create a bar chart with the measure , it is not giving me any data as it is text field.
Thanks & Regards
Shiv Kumar

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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