Forum Discussion
Anonymous
6 years agoNot applicable
Removing all text except certain characters
Hello, I'm new to using PowerQuery and I'm trying to clean up a column on one table to create a relationship with another table. The column I'm attempting to clean up is a free text field from a ...
Jimmy801
6 years agoCommunity Champion
Hello Anonymous
you can use a combination of Text.PositionOf and Text.Middle. Adding a try otherwise enablse to identifying those rows that don't contain any MA-****
let
Source = #table
(
{"FreeTextColumn"},
{
{"xxasdfMA-1450…sdf"}, {"sssktest MA-1111"}, {"kkMA-11558888884"}, {"88oeoeMA-15444"}
}
),
AddColumn = Table.AddColumn
(
Source,
"extract MA",
(add)=> try
Text.Middle
(
add[FreeTextColumn],
Text.PositionOf(add[FreeTextColumn], "MA-"),
7
)
otherwise
"contains NO MA-"
)
in
AddColumn
Copy paste this code to the advanced editor to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy