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
qsong
Helper II
Helper II

Convert string to number in DAX Function

Hello Community,

 

I connected to the source data through the online mode of the AAS model in Power BI, so I am not able to change formats of the datasets using the conventional ways (power query, for instance). Before doing the calculation, I need to convert the string to numerical value. For that, I used "Format", "value", or "convert", none of them worked for me because I cannot find the column in those formulas. For example, I have a string column "201908" and want to convert a value of 201908. Thank you.

2 ACCEPTED SOLUTIONS

@qsong - Use MAX or MIN


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Finally I used VALUE(MAX()) to refer the column names, and it works for me.

 

Thank you.

View solution in original post

9 REPLIES 9
Greg_Deckler
Super User
Super User

@qsong - Try [Column] * 1


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,

Thank you for your suggestion.

 

I cannot find the column except I have to add something like sum before the column; However, column has a string value, so sum does not work on the case.

 

Best, Qianru 

@qsong - Use MAX or MIN


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

I need to convert 123-45-789-0 is kind of string format data to number format ,could you please help me .

 

I need to logic to get additional values result 

For example,

 

 AI        Col-A    Col-B   Result

 A         123.     123.       Equal

 A         123.                  Extra 

 

I need to get extra for same document A

 

 

 

 

 

Finally I used VALUE(MAX()) to refer the column names, and it works for me.

 

Thank you.

@qsong , are you using live connection? Otherwise, you can simply change the data type to the number and it should work as long as all values in the column are number

I am using the live connection. So I cannot use power query to make the change.

Hi @qsong ,

 

Can you share the screenshot of your table and the column you want to convert.

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi @harshnathani,

 

I have a string column called calendar_month_key, and I want to convert it to be a numerical column called PP. As I described the background before, I am not able to do the format conversion in power query or by creating a calculated column because of the particular source connection. 

 

qsong_0-1599572561930.png

Currently, I am using the conditional statement for the conversion which consumes a lot of memory. So I cannot have enough space for further calculation. 

 

Thank you.

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