+ Reply to Thread
Results 1 to 10 of 10

Power Query - Extract strings only after the last delimiter

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    34

    Power Query - Extract strings only after the last delimiter

    Hi!
    I want to extract strings from a list using Power Query.
    This is my list

    list
    www.commerce.com/apple
    www.commerce.com/bus
    www.commerce.com/men/camp
    www.commerce.com/women/disco
    www.commerce.com/women/outfit/east
    www.commerce.com/women/outfit/dress/flamingo

    and I want to extract only the last string after the last slash "/', making the result like this:

    list
    apple
    bus
    camp
    disco
    east
    flamingo

    Hope anyone can help. Thanks!
    Last edited by uckycool; 10-06-2021 at 12:43 AM.

  2. #2
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,369

    Re: Power Query - Extract strings only after the last delimiter

    Try:

    =TRIM(RIGHT(SUBSTITUTE(TRIM(A1),"/",REPT(" ",255)),255))

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Power Query - Extract strings only after the last delimiter

    Since you are using Power Query, please update your profile which is still showing XL2007 for which PQ is not available.

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-01-2012
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    34

    Re: Power Query - Extract strings only after the last delimiter

    OK, my profile's changed now. thanks for letting me know alansidman.

    but turns out I'm giving my example wrong. some instances have another "/" in the back as well so extract after delimiter is not solving these instances.

    the original list should be like this (added "/" on the back of the strings for rows 3, 4, 5):

    list
    www.commerce.com/apple
    www.commerce.com/bus
    www.commerce.com/men/camp/
    www.commerce.com/women/disco/
    www.commerce.com/women/outfit/east/
    www.commerce.com/women/outfit/dress/flamingo

    with the expected result same like this:

    list
    apple
    bus
    camp
    disco
    east
    flamingo

    hope you also have answer to this? thank you.
    Last edited by AliGW; 10-06-2021 at 04:16 AM. Reason: PLEASE don't quote unnecessarily!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: Power Query - Extract strings only after the last delimiter

    Uh-oh - shifting goalpost alert!!!

    1. Must this be a PQ solution, or would a formula do?
    2. Are there any other possibilities that you haven't included here, or is this the full extent of the issue? Are the items to be extracted always going to be single words, for example?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    10-01-2012
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    34

    Re: Power Query - Extract strings only after the last delimiter

    Hi!
    1. yes must be in PQ
    2. yes, this is already the full extent of the issue. there might be a case where two words but joined by a dash "-", but the string shall be only surrounded by slash "/"
    Last edited by AliGW; 10-06-2021 at 04:36 AM. Reason: PLEASE don't quote unnecessarily!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: Power Query - Extract strings only after the last delimiter

    M Code:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Power Query - Extract strings only after the last delimiter

    you could use extract between, as opposed to splits etc, e.g.:

    Please Login or Register  to view this content.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: Power Query - Extract strings only after the last delimiter

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  10. #10
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,294

    Re: Power Query - Extract strings only after the last delimiter

    My version
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using Power Query to extract specific data
    By JasonWier in forum Excel General
    Replies: 1
    Last Post: 09-21-2021, 11:00 AM
  2. Replies: 0
    Last Post: 06-23-2021, 04:18 PM
  3. [SOLVED] Power Query connection only and extract values
    By misty15 in forum Office 365
    Replies: 2
    Last Post: 06-10-2021, 02:51 PM
  4. [SOLVED] Power Query Extract
    By AllisterB in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-17-2021, 05:49 PM
  5. Replies: 8
    Last Post: 10-21-2020, 03:02 AM
  6. Extract data from Web using Power Query
    By jatin.c in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-23-2020, 08:38 AM
  7. Power Query - Extract specific data from text and concatenate with delimiter
    By Riahon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2020, 11:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1