Forum Discussion
Convert long text containing both letters and numbers into a unique numeric representation.
- 1 year ago
Hi sudhisami_azure , You could use a calculate column for this could you please try this
Create a New Column:
- In the ribbon, select Modeling > New Column.
Dax Formula
NumericHash =
SUMX(
GENERATE(
ADDCOLUMNS(
MID([id], SEQUENCE(1, LEN([id])), 1),
"CharValue", UNICODE([Value])
),
ROW("Position", ROW_NUMBER())
),
[CharValue] * POWER(31, LEN([id]) - [Position])
)
Try thisIf this post helped please do give a kudos and accept this as a solution
Thanks In Advance - 1 year ago
Hi sudhisami_azure,
Thank you for reaching out to the Microsoft Fabric community.
I understand that you are looking to convert long text values in your Power BI dataset into numeric representations using ASCII values to optimize storage and improve performance.
Below is the M-Query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("3ZXLdWApDERz8boX6C+W6JeEp8OY/Ee2e5LoFe8dOKiqBJfPzw/4+PXh2IfbEY1U9InF8aijmiAACnGuX2WK51zXOXDeOZ4nxQkC/vn3HNQMTntw7g7VThnAljYAZs+ON4RrIr7evxp14FNoLhDckv6zi93dHXGLkdSTbBRvRQH3Yz5E2ocsBq5xilrKKY58d+a8lPfx+9fnB36ZOk+pNSrr4Z17ub+ceQmexHspaT2H8Wp2rOMGXgOPyxlu1o8clFAvPTs5ZgokuiuV2xj53Z0Rf/rexRmtaVWKuQTcXLDB/ewysmvzrF0f7NeQ8iWfNKQ3mF1PWTIVXcg9gS8vaxcddccD36ZoTVl6urxUyN5c6ZoN8bYEBJPZ5KkbbbOg9VWrR5LAZS4724v7I8cVxPTWjls67n5xkR8leBWayhsahJxt/E6w37FOuE8QaOhPp47oWlfxw1mx3e86EZ1jl1hBdcXThbfVXZufEXV3NQvBOOq3Kf4bTcnfaEr/RlP2ZUq+AJezWEp4PvLIp/luQaC90o29nLvHUJpi9Sw5Vqv0MgUWLD9ylCwrwx7L4RcQoaMz4yZ86daCw1i37lml+uBCLv9wQzmL0f/pV3vxh27rxjEXNqovGJ/wK0E8E4RQeYNosbdglKVlUxeb1kJcvk35t6l15Du7uu+z9QAHYIwlsLwWiLtPdRosjBUX/oWbDSI8rET+kUMlVXVsMb1qTr+1xjhXV8t972Xp0+vLcAbtscDIjEPIjrGx/jFFRvtewIMFrUQw6wax4fLdeKOBh+8+NrKnavYYpNg83TDrxfCxj9+//wM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [sno = _t, id = _t]),
AddHashColumn = Table.AddColumn(Source, "NumericHash", each
Number.Mod(
List.Sum(
List.Transform(
List.Zip({ List.Transform(Text.ToList([id]), each Character.ToNumber(_)), List.Reverse(List.Numbers(0, Text.Length([id])))}),
each _{0} * Number.Power(31, _{1})
)
), 1000000007
), type number
)
in
AddHashColumnIve also attached PBIX file below.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
Thanks Akash, could you provide me M-query? Because can not load the long text to file.