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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Fcoatis
Post Patron
Post Patron

Number.FromText syntax

Hi,

 

I have a custom column that is returning exactly what I want. That is, if a number is in "en-Us" use locale otherwise regional:

 

 

= Table.AddColumn(RemCol3, "Custom", each try Number.FromText([Custom1], "en-US") otherwise Number.FromText([Custom1]))

 

But the column "Custom" is returning as type any. According to documentation is possible to return as type number right?

 

 

Number.FromText(text as nullable text, optional culture as nullable text) as nullable number

 

I tried this with no succes. Any help?

 

= Table.AddColumn(RemCol3, "Custom", each try Number.FromText([Custom1], "en-US")as number otherwise Number.FromText([Custom1])as number)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Fcoatis ,

 

Based on your description, you can modify your M-query a little.

= Table.AddColumn(RemCol3, "Custom", each try Number.FromText([Custom1], "en-US") otherwise Number.FromText([Custom1]), type number)

v-yuaj-msft_0-1619508566380.png

You need to define your data type of this column, or the default type is "any".

Here is my test result.

v-yuaj-msft_1-1619508660252.png

v-yuaj-msft_2-1619508690138.png

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Fcoatis ,

 

Based on your description, you can modify your M-query a little.

= Table.AddColumn(RemCol3, "Custom", each try Number.FromText([Custom1], "en-US") otherwise Number.FromText([Custom1]), type number)

v-yuaj-msft_0-1619508566380.png

You need to define your data type of this column, or the default type is "any".

Here is my test result.

v-yuaj-msft_1-1619508660252.png

v-yuaj-msft_2-1619508690138.png

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

 

Fcoatis
Post Patron
Post Patron

@amitchandak Thanks for your suggestion. I know I can change the type in an additional step. I was wondering if I can change the type in one step, as mentioned in the code above?

amitchandak
Super User
Super User

@Fcoatis , In power query you have the option to change the data type, Change it to the number, and check

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors