The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
E.g., in I can have this string value in the column:
Раrtizаn
I would like this value to appear as
Partizan
Is it possible to transform a string which can contain any number of any HTML symbol (not using R or Py) ?
Solved! Go to Solution.
Html.Table works brilliantly! Full inspectable code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDAyUzY0MDWzhrPNjayLSjKrkPl5SrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "HtmlStep", each Html.Table([col1],{{"HtmlDecoded",":root"}})),
#"Expanded HtmlStep" = Table.ExpandTableColumn(#"Added Custom", "HtmlStep", {"HtmlDecoded"}, {"HtmlDecoded"})
in
#"Expanded HtmlStep"
Or without a new column:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDAyUzY0MDWzhrPNjayLSjKrkPl5SrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}}),
Decoded = Table.TransformColumns(#"Changed Type",
{{ "col1", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded",":root"}})) }} )
in
Decoded
Html.Table works brilliantly! Full inspectable code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDAyUzY0MDWzhrPNjayLSjKrkPl5SrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "HtmlStep", each Html.Table([col1],{{"HtmlDecoded",":root"}})),
#"Expanded HtmlStep" = Table.ExpandTableColumn(#"Added Custom", "HtmlStep", {"HtmlDecoded"}, {"HtmlDecoded"})
in
#"Expanded HtmlStep"
Or without a new column:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDAyUzY0MDWzhrPNjayLSjKrkPl5SrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}}),
Decoded = Table.TransformColumns(#"Changed Type",
{{ "col1", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded",":root"}})) }} )
in
Decoded
Hi @Zyg_D
Yes you can do this, here's the M code to copy/paste into a blank query, and a sample PBIX file
let
Codes = [1056 = "P", 1072 = "a"],
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDAyUzY0MDWzhrPNjayLSjKrkPl5SrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Text = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each List.RemoveMatchingItems(Text.SplitAny([Text],";&#"),{" "})),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Text.Combine(List.Transform([Custom], each try if Number.From(_) > 0 then Record.Field(Codes,_) else null otherwise _ ))),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
I've created a Record with the codes for P and a , you will need to add whatever other codes you need to this. You could use a List or a Table Column just as well, but the above code will need to be modified to accomodate this.
The code splits the text into separate codes and letters, replaces the code with the letter from the Codes Record then recombines everything.
Regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Thanks, @PhilipTreacy
This may work, but I would need to know beforehand which HTML codes I may get. Sadly I don't know what users will provide me with.
I know there is a DAX function UNICHAR, which decodes all those numeric values into symbols, but I don't know how to deploy it so that it would read any number of occurrences.
@Zyg_D , Not very clear
refer :https://www.youtube.com/watch?v=4UDynnPQpG4
https://www.youtube.com/watch?v=Wz2aD0XvkUk
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
79 | |
71 | |
48 | |
41 |
User | Count |
---|---|
138 | |
108 | |
71 | |
64 | |
58 |