Forum Discussion
smko
5 years agoHelper I
Conditional column to match a range of substring
I have Column A from a dataset, I need to make the result into Column B, basically every result must have calling code in front. While I can write a really long ugly code something like below,...
- 5 years ago
Hi smko
How about
= if Text.StartsWith([Column A], "01") and List.Contains({"0".."9"}, Text.Middle([Column A],2)) and Text.Length([Column A])>=10 and Text.Length([Column A])<=11 then "+6"&[Column A] else nullYou'll have to update the else clause
Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
AlB
5 years agoCommunity Champion
Hi smko
How about
= if Text.StartsWith([Column A], "01") and List.Contains({"0".."9"}, Text.Middle([Column A],2))
and Text.Length([Column A])>=10 and Text.Length([Column A])<=11
then "+6"&[Column A] else null
You'll have to update the else clause
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
smko
5 years agoHelper I
Excellent!! Thank you for saving my ugly code. There is one small mistake though, text.middle should be
Text.Middle([Column A],2,1)otherwise it grab entire string after 2nd position