Forum Discussion
Counting multiple characters in a single column
- 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.
Thank you for this. I have had another problem arise. Was wondering if it is possible to keep these counts linked to an identity for filtering purposes?
Yea, it is possible.
In the first step, just reference the table instead of only taking the Codes column. I.e. instead of MyTable[[Codes]] use MyTable
Then after you do the split, your next step would be to expand list column. The remaining step in group by would be the same, except you would group by 2 columns (id and code).