Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I was trying to find a way to decode a text field that has been encoded in base64?
I know there is a function named BinaryEncoding.Base64 which I assume allows you to encode a string, but I can't see a decode one in the docs?
Many thanks,
Dom
Solved! Go to Solution.
Hi @Anonymous ,
I think below formula will suitable for your requirement:
Lines.FromBinary(Binary.FromText(text,BinaryEncoding.Base64), null, null, 1252){0}
Full query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WigoPyvGtSjbxCwkt8c1yNI0KNjDwc/HL9Ql3y4gM9yyJyvU08Q0JNYgKCcv1DwnLUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Lines.FromBinary(Binary.FromText([Column1],BinaryEncoding.Base64), null, null, 1252){0})
in
#"Added Custom"
Regards,
Xiaoxin Sheng
Hi @Anonymous ,
Actually, BinaryEncoding.Base64 only means the encoding format.
According to your description, I think binary functions will suitable for your requirements. You can use power query functions to encode and decode your characters.
Reference links:
Binary.ToText | Encodes binary data into text format. |
Binary.FromText | Decodes data from text into binary. |
Sample:
Custom = Binary.ToText(Binary.FromText("0200057b094a3a00e57d000000000000", BinaryEncoding.Base64),BinaryEncoding.Hex)
Regards,
Xiaoxin Sheng
Hi Xiaoxin,
Thanks or your response, that got me a step further, however I need to the string to be converted to a string value rather than a hex value.
e.g. the value
ZWRlMzc4NTUtMjA5ZS00NDNmLWFhYWItZmI4MTU0ZTVmOTVj
would be converted to the string value:
ede37855-209e-443f-aaab-fb8154e5f95c
instead of the hex value:
65646533373835352d323039652d343433662d616161622d666238313534653566393563
Is that possible?
Many thanks,
Dom
Hi @Anonymous ,
I think below formula will suitable for your requirement:
Lines.FromBinary(Binary.FromText(text,BinaryEncoding.Base64), null, null, 1252){0}
Full query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WigoPyvGtSjbxCwkt8c1yNI0KNjDwc/HL9Ql3y4gM9yyJyvU08Q0JNYgKCcv1DwnLUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Lines.FromBinary(Binary.FromText([Column1],BinaryEncoding.Base64), null, null, 1252){0})
in
#"Added Custom"
Regards,
Xiaoxin Sheng
Hi Xiaoxin,
I've placed this code but the table seems to be empty:
= Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i44FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t])
Is there a reason why?
Because "i44FAA==" decodes and decompresses into "[]" which is an empty array.
Thanks Xiaoxin that worked a treat!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
77 | |
59 | |
36 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
48 | |
41 |