Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello,
I need some help removing a symbol ("-") if it exists in the beginning of a column value, but keep it if it exists elswhere in the value (not at the beginning).
E.g.:
Column | Result Column |
-alex | alex |
john | john |
a-albert | a-albert |
-dan | dan |
b-judy | b-judy |
Any thoughts?
Thanks!
Solved! Go to Solution.
I have used a series of steps in "Power query".
please find below the query code with all the steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0s1LzE1VitWJVipJLS7RLUBiFujqKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Test", type text}}),
#"Inserted First Characters" = Table.AddColumn(#"Changed Type", "First Characters", each Text.Start([Test], 1), type text),
#"Extracted Text Range" = Table.TransformColumns(#"Inserted First Characters", {{"Test", each Text.Middle(_, 1, 10000000), type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Extracted Text Range","-","",Replacer.ReplaceText,{"First Characters"}),
#"Merged Columns" = Table.CombineColumns(#"Replaced Value",{"First Characters", "Test"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
I also found a way to do it in DAX:
CleanUp = IF(LEFT([Column], 1)="-", MID([Column], 2,LEN([Column])),[Column])
I also found a way to do it in DAX:
CleanUp = IF(LEFT([Column], 1)="-", MID([Column], 2,LEN([Column])),[Column])
I have used a series of steps in "Power query".
please find below the query code with all the steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0s1LzE1VitWJVipJLS7RLUBiFujqKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Test = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Test", type text}}),
#"Inserted First Characters" = Table.AddColumn(#"Changed Type", "First Characters", each Text.Start([Test], 1), type text),
#"Extracted Text Range" = Table.TransformColumns(#"Inserted First Characters", {{"Test", each Text.Middle(_, 1, 10000000), type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Extracted Text Range","-","",Replacer.ReplaceText,{"First Characters"}),
#"Merged Columns" = Table.CombineColumns(#"Replaced Value",{"First Characters", "Test"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"
Hi, @Uspace87,
Thanks a lot, this helps. Can you let me know how you added the "Inserted First Characters" step?
Best regards!
Thank you!
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
19 | |
14 | |
10 | |
7 |