Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Is there a way to decode a base64 text field?

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

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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"

9.png
Regards,

Xiaoxin Sheng

View solution in original post

7 REPLIES 7
luizhrocha
New Member

Anonymous
Not applicable

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)

8.png

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

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

Anonymous
Not applicable

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"

9.png
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.

Anonymous
Not applicable

Thanks Xiaoxin that worked a treat!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.