Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello!
I'm looking to write a condition that checks that a text exists between two delimiters (without extraction). Exemple :
Data = aaa bbb ccc ddd eee rrr
How to check that "ccc" exists between "bbb" and "ddd"?
Thanks!
Solved! Go to Solution.
You could use Regular Expressions (and @ImkeF has a blog on using them), or you could split your string on the space, and check that the delimiters are present and in the correct order.
i.e:
Edited to account for missing delimiter as the first element
#"Added Custom" = Table.AddColumn(#"Previous Step", "Matches", each
let
split = Text.Split([Column with the strings to be tested]," "),
params = {"bbb"} & {"ccc"} & {"ddd"},
pos = List.Accumulate(params,{},(x,y)=> x & {List.PositionOf(split,y)})
in
in
if List.Contains(pos,-1) then false else
pos{0} < pos{1} and pos{1} < pos{2}, type logical)
Hi @Anonymous ,
would that work for you?:
Text.BetweenDelimiters("aaa bbb ccc ddd eee rrr", "bbb ", " ddd") = "ccc"
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Thanks ! it works fine when there are no values between "ccc" and "bbb" or "ddd"
How do I do the same for this case :
Data = aaa bbb xxx ccc ttt ddd eee rrr
How to verify that "ccc" exists between "bbb" and "ddd"
You could use Regular Expressions (and @ImkeF has a blog on using them), or you could split your string on the space, and check that the delimiters are present and in the correct order.
i.e:
Edited to account for missing delimiter as the first element
#"Added Custom" = Table.AddColumn(#"Previous Step", "Matches", each
let
split = Text.Split([Column with the strings to be tested]," "),
params = {"bbb"} & {"ccc"} & {"ddd"},
pos = List.Accumulate(params,{},(x,y)=> x & {List.PositionOf(split,y)})
in
in
if List.Contains(pos,-1) then false else
pos{0} < pos{1} and pos{1} < pos{2}, type logical)
Thanks a lot !
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.