Text.FromBinary is a Power Query M function that decodes binary data into a text value using a specified encoding type. The function returns the decoded text value.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Text.FromBinary(
binary as nullable binary,
optional encoding as nullable number,
) as nullable text
Argument | Attribute | Description |
---|---|---|
binary | ||
encoding | optional | Uses the TextEncoding.Type to specify the text’s binary encoding format. By default, if not provided, the argument uses TextEncoding.Utf8 (UTF8 binary form). Other available options are: – TextEncoding.Unicode: use the UTF16 little-endian binary form. – TextEncoding.Utf16: use the UTF16 little-endian binary form. – TextEncoding.BigEndianUnicode: use the UTF16 big endian binary form. – TextEncoding.Windows: use the Windows binary form. – TextEncoding.Ascii: use the ASCII binary form. |
Description
The Text.FromBinary function converts binary data back into a text string in Power Query M. You can specify an encoding type to use for the decoding operation.
Examples
The Text.FromBinary function can be particularly useful in certain scenarios, such as identifying diacritic characters in a text string. Let’s explore how this function works with a couple of examples.
Converting Text with Diacritics to Binary and Back
Suppose you have the text “OldÅ™ich Nejedlý” and want to convert it to binary using Text.ToBinary
. Then, you convert it back to text using Text.FromBinary
. Instead of returning the original diacritic characters (like Å™), it returns a question mark (?) wherever it encounters such a character.
// Output: "Old?ich Nejedl?"
let
toBinary = Text.ToBinary( "Oldřich Nejedlý", 1361 ),
toText = Text.FromBinary( toBinary )
in
toText
This method can help you identify how many diacritic characters are in a string and their positions, based on where the question marks appear in the output. Let’s take another example with the text “Dražan Jerković”.
// Output: "Dra?an Jerkovi?"
let
toBinary = Text.ToBinary( "Dražan Jerković", 1361 ),
toText = Text.FromBinary( toBinary )
in
toText
To find the positions of these question marks, you can use the Text.PositionOfAny function with the Occurrence.All enumeration. This will help you locate where the diacritic characters were originally placed in the text.
// Output of toText = "Dra?an Jerkovi?"
// Output of Positions = { 3, 11 }
let
toBinary = Text.ToBinary( "Dražan Jerković", 1361 ),
toText = Text.FromBinary( toBinary ),
Positions = Text.PositionOfAny( toText, { "?" }, Occurrence.All )
in
Positions
Related functions
Other functions related to Text.FromBinary are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy