This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowThe Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more
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 maintenance system, and the goal is to remove all unrequired text and leave only what we want EX: MA-1405.
I've played around with the Replace Values tool, trying to remove and change as much as I can to then extract text before delimiter, however with it being a free text field there are plenty of delimiters and occassionally there is text before the MA#
I know that in Excel you can use ** to represent a string of characters and was wondering if a similar feature existed here as well?
Ideally I'd like to put in one formula to replace all values except "MA-***"
You can add a column with this formula, then remove the original column, and presumably filter out the rows that return null.
if Text.Contains([Column1],"MA-") = true
then Text.Middle([Column1],Text.PositionOf([Column1],"MA-"),7)
else null
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHello @Anonymous
have you been able to solve the problem with the replies given?
If so, 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
All the best
Jimmy
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
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |