cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
raymondpocher
Advocate II
Advocate II

PowerQuery: remove text string between custom delimiters

Hi community,

 

I want to achieve something simple but in power query I feel as if I am making way too compley. So after not finding anything on google I turn to you 🙂

 

Suppose I have loaded URLs into PowerQuery. Here a sample input:

.com/watch?t=606&v=rpcd-MEmzAc&ebc=ANyPxKo6RT9WxuEfw

 

I am now looking for a method to remove certain texts (above in bold):

.com/watch?v=rpcd-MEmzAc   

t=606& (string starting with a t= and ending with an or nothing)

&ebc=ANyPxKo6RT9WxuEfw (string starting with &ebc= and ending with an or nothing)

 

I tried:

 #"REMOVE" = Table.TransformColumns(#"PREVIOUS_STEP", {{"COLUMN_TO_REPLACE", each Text.Remove(_, Text.BetweenDelimiters(_, "t=", "&") ), type text}})

 

But in case the Parameter doesn't occur at all I will receive an error. It should only then replace the value if it is possible. 

 

 

1 ACCEPTED SOLUTION
CNENFRNL
Super User
Super User

#"REMOVE" = Table.TransformColumns(#"PREVIOUS_STEP", {{"COLUMN_TO_REPLACE", each Text.Replace(_, Text.BetweenDelimiters(_, "t=", "&"), ""), type text}})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Super User
Super User

#"REMOVE" = Table.TransformColumns(#"PREVIOUS_STEP", {{"COLUMN_TO_REPLACE", each Text.Replace(_, Text.BetweenDelimiters(_, "t=", "&"), ""), type text}})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.