Forum Discussion
Extract numbers from a string and add a space
- Anonymous4 years ago
Hi Anonymous
(1)For your first question , you can realize it in Power Query Editor . Add a customer column with the formula below .
Table.AddColumn(#"Changed Type", "Custom", each Text.Select([Justification],{"0".."9"," "}))
You will get the result below :
(2)For your second question , you can split the custom column you created before. You will get the following result.
Then go back to Desktop view, to judge whether these two columns can returns 7 digits that begins with a 2 or 6 . If yes , return 1 , or return 0 .We create two measures to judge .
find 1 = var _firstnumber=LEFT(SELECTEDVALUE('Table'[Custom.1]),1) var _number=LEN(SELECTEDVALUE('Table'[Custom.1])) return IF(_number=7 &&_firstnumber="2" || _firstnumber="6",1,0)find 2 = var _firstnumber=LEFT(SELECTEDVALUE('Table'[Custom.2]),1) var _number=LEN(SELECTEDVALUE('Table'[Custom.2])) return IF(_number=7 &&_firstnumber="2" || _firstnumber="6",1,0)The result is as shown :
Then create a measure to return the value that contain 7 digits and begin with a 2 or 6 .
final result = SWITCH(TRUE(),[find 1]=1,SELECTEDVALUE('Table'[Custom.1]),[find 2]=1,SELECTEDVALUE('Table'[Custom.2]))The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
(1)For your first question , you can realize it in Power Query Editor . Add a customer column with the formula below .
Table.AddColumn(#"Changed Type", "Custom", each Text.Select([Justification],{"0".."9"," "}))
You will get the result below :
(2)For your second question , you can split the custom column you created before. You will get the following result.
Then go back to Desktop view, to judge whether these two columns can returns 7 digits that begins with a 2 or 6 . If yes , return 1 , or return 0 .We create two measures to judge .
find 1 =
var _firstnumber=LEFT(SELECTEDVALUE('Table'[Custom.1]),1)
var _number=LEN(SELECTEDVALUE('Table'[Custom.1]))
return IF(_number=7 &&_firstnumber="2" || _firstnumber="6",1,0)find 2 =
var _firstnumber=LEFT(SELECTEDVALUE('Table'[Custom.2]),1)
var _number=LEN(SELECTEDVALUE('Table'[Custom.2]))
return IF(_number=7 &&_firstnumber="2" || _firstnumber="6",1,0)
The result is as shown :
Then create a measure to return the value that contain 7 digits and begin with a 2 or 6 .
final result = SWITCH(TRUE(),[find 1]=1,SELECTEDVALUE('Table'[Custom.1]),[find 2]=1,SELECTEDVALUE('Table'[Custom.2]))
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous4 years agoNot applicable
Thank you so much! I never would have figured that out!!!!