Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
ngct1112
Post Patron
Post Patron

PowerQuery - Text before multiple Delimiters

Hi,

 

May I know is there any way I could split text before multiple Delimiters in one function?

Original ColumnDesired Result
1 & 51
50 - 100050
1000/20001000
2000&50002000
5000/100005000

 

Great thanks!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Add a step to extract the text before one of those delimiters, and then modify the code in the formula bar to look like this

 

= Table.TransformColumns(Source, {{"Column1", each Text.Start(_, Text.PositionOfAny(_, {"&", "/", "-"})), type text}})

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
ngct1112
Post Patron
Post Patron

@mahoneypat it works in my query. Very brilliant. Thanks for your help!

mahoneypat
Microsoft Employee
Microsoft Employee

Add a step to extract the text before one of those delimiters, and then modify the code in the formula bar to look like this

 

= Table.TransformColumns(Source, {{"Column1", each Text.Start(_, Text.PositionOfAny(_, {"&", "/", "-"})), type text}})

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


In case other people struggle with changing the 'text before delimiter' line into TransformColumns, like I did, here is some clarification: 

 

 

= Table.TransformColumns(#"NameOfPreviousQueryStep", {{"Original column you want to edit", each Text.Start(_, Text.PositionOfAny(_, {"&", "/", "-", "any other symbols"})), type text}})

 

 

So don't expect to create a new column!

@mahoneypat ,

Two follow-on questions:

  1. How might I add null handling? It seems that Power Query returns an error if it doesn't find any of the specific delimiters.
  2. How would I extract the text after the first space OR after the first "-"? I used Text.Middle instead of Text.Start which works for the space, but still includes the "-" in the extracted text. 

Thank you,

 

-Travis

how can this be done with a multiple character string?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors