Forum Discussion
k_mathana
5 years agoHelper II
Add Asterisk between Numeric and Alphabets
Hi, Could you please kindly support to solve this requirement, I need to add Asterisk character between the Numeric and Alphabets . VALUE Expected Result 2Z-0001 2*Z*0001 124S120 124*S*...
- 5 years ago
Hi k_mathana
Download sample PBIX file with solution
This Power Query M code does the job.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMorSNTAwMFSK1YlWMjQyCTY0MgCzTY1MHA2NTR2hEkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]), #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Combine(List.Transform(Text.ToList([Value]), each if Text.Contains("ABCDEFGHIJKLMNOPQRSTUVWXYZ", _) then "*" & _ & "*" else _ ))), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if List.Last(Text.ToList([Custom])) = "*" then Text.Combine(List.RemoveLastN(Text.ToList([Custom]))) else [Custom]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"}) in #"Removed Columns"Regards
Phil
PhilipTreacy
5 years agoSuper User
Hi k_mathana
Download sample PBIX file with solution
This Power Query M code does the job.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMorSNTAwMFSK1YlWMjQyCTY0MgCzTY1MHA2NTR2hEkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Combine(List.Transform(Text.ToList([Value]), each if Text.Contains("ABCDEFGHIJKLMNOPQRSTUVWXYZ", _) then "*" & _ & "*" else _ ))),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if List.Last(Text.ToList([Custom])) = "*" then Text.Combine(List.RemoveLastN(Text.ToList([Custom]))) else [Custom]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
Regards
Phil
k_mathana
5 years agoHelper II
Thank you so much, it worked....