Forum Discussion
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?
- Anonymous3 years ago
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", _)), "")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.
3 Replies
- AnonymousNot applicable
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", _)), "")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.
- DA_BNew Member
Hi Anonymous 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
qnpfJust 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