Forum Discussion

wharrison999's avatar
wharrison999
Frequent Visitor
7 years ago
Solved

Custom Column - Order Number extraction from Description Column

Hi Everyone,   Please could someone help me.   I need to create a custom column to extract the order number from a description column.   Unfortuntatly the data I am working with is quite messy ...
  • OwenAuger's avatar
    OwenAuger
    7 years ago

    Hi again Wendy,

    Sure thing - yes the above is an illustration and the idea is to put the Added Custom step into your own query.

     

    I'm assuming you are starting with a table in the Power Query editor containing a Description column.

    Then you should go to the ribbon => Add Column => Custom Column

    then enter this code in the dialog box

    let
      nums = {"0".."9"},
      CharList = Text.ToList([Description]),
      OrderNo = List.Accumulate(
        CharList, "", (state,current)=>if Text.Length(state)=6 then state else if List.Contains(nums,current) then state & current else ""
      )
    in OrderNo

    It should look like this:

     

     

    Best regards,

    Owen