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
Aman_
Frequent Visitor

How to Convert Text values (with Million dollar and Billion dollar) to number in Power BI

Hi

I have text values in one column containing values like $2.5M and $4.5B . I have to convert this column into numerical column so that I can do calculation on this . Please provide solution

 

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Aman_ create this column in DAX:

 

Column = 
VAR _factor = RIGHT(Table1[Column1])
VAR _number = VALUE(LEFT(Table1[Column1], LEN(Table1[Column1]) - 1 ))
VAR _result = 
SWITCH(
    TRUE(),
    _factor = "B", _number * 1000000000,
    _factor = "M", _number * 1000000
)
RETURN
    _result

 

 

SpartaBI_0-1651062075775.png


In case it solved your question, pleasw accept this as a solution. Appreciate your Kudos.

View solution in original post

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@Aman_ 
Power Query: replace all the characters that are no digits with nothing. 


SpartaBI_0-1651060748447.png

Than change the type of the column from TEXT to whole number or currency and upload to the model.
You can always format them with $ again in the model.

Hi

Thank you for your reply , In column Some values are given in M (Million) and Some in given as B (Billion) like 2.5M , 1.5B, 7.0M . How to deal with this and convert into single format say thousand

SpartaBI
Community Champion
Community Champion

@Aman_ create this column in DAX:

 

Column = 
VAR _factor = RIGHT(Table1[Column1])
VAR _number = VALUE(LEFT(Table1[Column1], LEN(Table1[Column1]) - 1 ))
VAR _result = 
SWITCH(
    TRUE(),
    _factor = "B", _number * 1000000000,
    _factor = "M", _number * 1000000
)
RETURN
    _result

 

 

SpartaBI_0-1651062075775.png


In case it solved your question, pleasw accept this as a solution. Appreciate your Kudos.

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.