Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi! I need some help please :).
I want to replace two characters ONLY if are placed at the end of string of one column.
I'm using Power Query and the following Query to replace the " L" characters (notice the leading space).
= Table.ReplaceValue(#"Ant_Query"," L","",Replacer.ReplaceText,{"COLUMN_TO_APPLY"})
But the results are not what I need.
Desirable:
"TEST L" --> "TEST"
"TEST LONG" --> "TEST LONG"
"TEST LONG L" --> "TEST LONG"
Actual:
"TEST L" --> "TEST"
"TEST LONG" --> "TESTONG"
"TEST LONG L" --> "TESTONG"
Using the "( L)$" Regex to search and replace the value would do the trick.
TY very much for the help, and Regards!
Solved! Go to Solution.
You can use the following formula:
= Table.TransformColumns(
Ant_Query,
{{"COLUMN_TO_APPLY",
each if Text.EndsWith(_," L")
then Text.Start(_,Text.Length(_)-2)
else _,
type text}})
You can use the following formula:
= Table.TransformColumns(
Ant_Query,
{{"COLUMN_TO_APPLY",
each if Text.EndsWith(_," L")
then Text.Start(_,Text.Length(_)-2)
else _,
type text}})
It works!, TY very much (:
User | Count |
---|---|
73 | |
70 | |
38 | |
24 | |
23 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |