Forum Discussion

NPC's avatar
NPC
Helper I
3 years ago
Solved

Extract specific numbers from a group

Hello,   Hope you can help with this.   I have a table that looks like this: Transaction ID Extracts 1 021, 003, 022, 603, 415 2 002, 001, 408, 510 3 005, 004, 006, 510, 415, 408...
  • Shaurya's avatar
    3 years ago

    Hi NPC,

     

    You can extract these specific numbers from a group by using list functions.

     

    Create a custom column using this M Code:

     

     

    Extract = List.Last(List.Select(Text.Split([Extracts],","), each _ <= "006"))

     

     

    This code will:

    1. Convert your group into a list.
    2. Filter out everything except {001..006}.
    3. Return the right most element from that list.

     

    In case you don't have any number from 001 to 006 in your group, you'll get a null value.

     

     

    Works for you? Mark this post as a solution if it does!