Power BI: extract numbers and/or text
To extract numbers, text or any characters, the easy way to do it is from the Power Query Editor, from there, just click on “add column -> custom column”:
There are 2 functions that I can use:
- Text.Select: select the specified characters
Text.Select([argument],{"value1".."value2"}) - Text.Remove: remove the specified characters
Text.Remove([argument],{"value1".."value2"})
And to remove unuseful spaces:
- Text.Combine(List.Select(Text.SplitAny([argument], " #(lf)#(cr)"), each _<>""), " ")
![]() |
![]() |
![]() |
Both work the same way and based on what I want, they can give me the same results or not. They are case sensitives so if I said to remove small characters (for instance “a”), it will keep capital ones (for instance “A”):
I will use Text.Select for my examples from now on to not duplicate. For numbers, just replace the letters:
To get decimal numbers, I will need to add the separator:
Text.Select([argument],{"value1".."value2","."})
NOTE: if the separator is a coma for instance, just replace "." by ","
In case if it can’t find what I request or to ignore errors, I can tell it to put something else:
try ... otherwise value
NOTE: change “value” by yours or by “null” for an empty cell
To combine both or more options, just add it like that:
Text.Select([argument],{"value1".."value2","value3".."value4"})
With those 2 functions, I can select or remove what I want. The important rule to respect is that the decimal “value1” should be inferior to “value2”. For instance:
- This formula will work:
- This formula will not work:
In this wikipedia decimal unicode page, I can find the information and as you can see, ! has 33 and ) has 41:
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...









