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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
DA_B
New Member

text to Number - try otherwise?

Hey,

 

i've got a little problem. I have a large data set (multiple collumns and rows) which is split in dates (TTMMJJJJ), text and real number cells.

I can easily change the date collums from text do date. But the rest ist mixed togehter. If i try to change the type i get Error's - if i use the "Json" Tool to. Ive already tried to work with an try otherwise formula but it wont change the type, all i get is the cell replaced with "Type".

Is there also a easy way to change multiple collums at once?

 

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

Hi @DA_B ,

 

In general, a column that mix numbers and text in Power Query cannot be defined as numeric types.

If it is easy to extract numbers in your column, you can try the following formula.

=Text.Combine(List.Select(Text.ToList([Column1]), each Text.Contains("0123456789", _)), "")

vstephenmsft_0-1685071250145.png

This formula works by converting the text in the column to a list of characters using the Text.ToList function, and then selecting only the characters that are numbers using the List.Select function and the Text.Contains function. The resulting list of numbers is then combined back into a single text string using the Text.Combine function.


Note that this formula will only extract numbers that are contiguous in the text string. If there are non-numeric characters between the numbers, they will be ignored. If you need to extract numbers that are separated by non-numeric characters, you will need to modify the formula accordingly.

 

Best Regards,

Stephen Tao

 

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
v-stephen-msft
Community Support
Community Support

Hi @DA_B ,

 

In general, a column that mix numbers and text in Power Query cannot be defined as numeric types.

If it is easy to extract numbers in your column, you can try the following formula.

=Text.Combine(List.Select(Text.ToList([Column1]), each Text.Contains("0123456789", _)), "")

vstephenmsft_0-1685071250145.png

This formula works by converting the text in the column to a list of characters using the Text.ToList function, and then selecting only the characters that are numbers using the List.Select function and the Text.Contains function. The resulting list of numbers is then combined back into a single text string using the Text.Combine function.


Note that this formula will only extract numbers that are contiguous in the text string. If there are non-numeric characters between the numbers, they will be ignored. If you need to extract numbers that are separated by non-numeric characters, you will need to modify the formula accordingly.

 

Best Regards,

Stephen Tao

 

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

Hi @v-stephen-msft and @BA_Pete,

 

thank you guys for your Input. I've made a mini version of my data set i had to import into excel. It looked like:

 

100
"test1","test2","test3"
"31.12.2020","1","1.9"
"31.12.2021","1.5","1"
"31.12.2022","0","1"
"31.12.2023","x","0.3"
"31.12.2024","0","0"
"31.12.2025","y","0"
"31.12.2026","0","0"
"31.12.2027","1.1","y"
"31.12.2028","0","y"
"31.12.2029","1","x"

"end"
reanwf2r1p
qnpf

 

Just imagine it like 250k times 200 instead of 15 times 3.

 

My solution was quite simple: I've switches excel to the english version and imported the data (outside of Power Query). After that i simply changed it back to european (, instead of .) and i was done. 

Now everything is type standard and works accordingly.

 

Thank you for your time and effort.

 

Best Regards,

Daniel

BA_Pete
Super User
Super User

Hi @DA_B ,

 

You'll need to provide some copyable example data and what your expected output looks like please.

You can either paste directly from Excel into a post, or copy/paste the M code from an 'Enter Data' query.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors