Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Counting multiple characters in a single column

Hi, so I have a column which is ordered by ID numbers and in each row there is often multiple "codes" (each code is always 2 letters long seperated by a space . I have included a table of what these ...
  • artemus's avatar
    6 years ago

    First the easy question: How to get a column with the last code:

    Click the column, then in the Add column tab, choose extract -> Text after delimiter. Enter space as your delimiter, and in advanced options, choose from end of input.

     

    Now for the frequency of the  codes:

    In a new query, create a new blank query with:

    = MyTable[[Codes]] 

    Where MyTable is the name of your query with the codes

     Now go to Transform -> Extract -> Text After delimiter, and enter in ~ to remove it from the column

    Next add a new custom column, call it CodeList with the formula:

    = Text.Split([Codes], " ")

    Now add a new custom step (right click the query step list and choose insert step) with:

    = List.Combine(#"Added Custom"[CodeList])

    Assuming that Added Custom was the name of your previous step.

    Next, click ToTable button with default options to turn it back into a table.

    Finally, choose Group By, and leave the default options. This should give you the table of 2 letter code to count.