A
- AccessControlEntry.ConditionToIdentities
- Access.Database
- ActiveDirectory.Domains
- AdobeAnalytics.Cubes
- AdoDotNet.DataSource
- AdoDotNet.Query
- AnalysisServices.Database
- AnalysisServices.Databases
- AzureStorage.BlobContents
- AzureStorage.Blobs
- AzureStorage.DataLake
- AzureStorage.DataLakeContents
- AzureStorage.Tables
B
- BinaryFormat.Binary
- BinaryFormat.Byte
- BinaryFormat.ByteOrder
- BinaryFormat.Choice
- BinaryFormat.Decimal
- BinaryFormat.Double
- BinaryFormat.Group
- BinaryFormat.Length
- BinaryFormat.List
- BinaryFormat.Null
- BinaryFormat.Record
- BinaryFormat.SignedInteger16
- BinaryFormat.SignedInteger32
- BinaryFormat.SignedInteger64
- BinaryFormat.Single
- BinaryFormat.Text
- BinaryFormat.Transform
- BinaryFormat.UnsignedInteger16
- BinaryFormat.UnsignedInteger32
- BinaryFormat.UnsignedInteger64
- BinaryFormat.7BitEncodedSignedInteger
- BinaryFormat.7BitEncodedUnsignedInteger
- Binary data
- Binary.ApproximateLength
- Binary.Buffer
- Binary.Combine
- Binary.Compress
- Binary.Decompress
- Binary.From
- Binary.FromList
- Binary.FromText
- Binary.InferContentType
- Binary.Length
- Binary.Range
- Binary.Split
- Binary.ToList
- Binary.ToText
- Binary.View
- Binary.ViewError
- Binary.ViewFunction
- Byte.From
C
- Cdm.Contents
- Character.FromNumber
- Character.ToNumber
- Combiner.CombineTextByDelimiter
- Combiner.CombineTextByEachDelimiter
- Combiner.CombineTextByLengths
- Combiner.CombineTextByPositions
- Combiner.CombineTextByRanges
- Comparer.FromCulture
- Comparer.Ordinal
- Comparer.OrdinalIgnoreCase
- Controlling byte order
- Csv.Document
- Cube.AddAndExpandDimensionColumn
- Cube.AddMeasureColumn
- Cube.ApplyParameter
- Cube.AttributeMemberId
- Cube.AttributeMemberProperty
- Cube.CollapseAndRemoveColumns
- Cube.Dimensions
- Cube.DisplayFolders
- Cube.MeasureProperties
- Cube.MeasureProperty
- Cube.Measures
- Cube.Parameters
- Cube.Properties
- Cube.PropertyKey
- Cube.ReplaceDimensions
- Cube.Transform
- Currency.From
D
- DateTime.AddZone
- DateTime.Date
- DateTime.FixedLocalNow
- DateTime.From
- DateTime.FromFileTime
- DateTime.FromText
- DateTime.IsInCurrentHour
- DateTime.IsInCurrentMinute
- DateTime.IsInCurrentSecond
- DateTime.IsInNextHour
- DateTime.IsInNextMinute
- DateTime.IsInNextNHours
- DateTime.IsInNextNMinutes
- DateTime.IsInNextNSeconds
- DateTime.IsInNextSecond
- DateTime.IsInPreviousHour
- DateTime.IsInPreviousMinute
- DateTime.IsInPreviousNHours
- DateTime.IsInPreviousNMinutes
- DateTime.IsInPreviousNSeconds
- DateTime.IsInPreviousSecond
- DateTime.LocalNow
- DateTime.Time
- DateTime.ToRecord
- DateTime.ToText
- Date.AddDays
- Date.AddMonths
- Date.AddQuarters
- Date.AddWeeks
- Date.AddYears
- Date.Day
- Date.DayOfWeek
- Date.DayOfWeekName
- Date.DayOfYear
- Date.DaysInMonth
- Date.EndOfDay
- Date.EndOfMonth
- Date.EndOfQuarter
- Date.EndOfWeek
- Date.EndOfYear
- Date.From
- Date.FromText
- Date.IsInCurrentDay
- Date.IsInCurrentMonth
- Date.IsInCurrentQuarter
- Date.IsInCurrentWeek
- Date.IsInCurrentYear
- Date.IsInNextDay
- Date.IsInNextMonth
- Date.IsInNextNDays
- Date.IsInNextNMonths
- Date.IsInNextNQuarters
- Date.IsInNextNWeeks
- Date.IsInNextNYears
- Date.IsInNextQuarter
- Date.IsInNextWeek
- Date.IsInNextYear
- Date.IsInPreviousDay
- Date.IsInPreviousMonth
- Date.IsInPreviousNDays
- Date.IsInPreviousNMonths
- Date.IsInPreviousNQuarters
- Date.IsInPreviousNWeeks
- Date.IsInPreviousNYears
- Date.IsInPreviousQuarter
- Date.IsInPreviousWeek
- Date.IsInPreviousYear
- Date.IsInYearToDate
- Date.IsLeapYear
- Date.Month
- Date.MonthName
- Date.QuarterOfYear
- Date.StartOfDay
- Date.StartOfMonth
- Date.StartOfQuarter
- Date.StartOfWeek
- Date.StartOfYear
- Date.ToRecord
- Date.ToText
- Date.WeekOfMonth
- Date.WeekOfYear
- Date.Year
- DB2.Database
- Decimal.From
- Diagnostics.ActivityId
- Diagnostics.Trace
- DirectQueryCapabilities.From
- Double.From
- Duration.Days
- Duration.From
- Duration.FromText
- Duration.Hours
- Duration.Minutes
- Duration.Seconds
- Duration.ToRecord
- Duration.TotalDays
- Duration.TotalHours
- Duration.TotalMinutes
- Duration.TotalSeconds
- Duration.ToText
E
F
G
H
I
L
- Lines.FromBinary
- Lines.FromText
- Lines.ToBinary
- Lines.ToText
- List.Accumulate
- List.AllTrue
- List.Alternate
- List.AnyTrue
- List.Average
- List.Buffer
- List.Combine
- List.ConformToPageReader
- List.Contains
- List.ContainsAll
- List.ContainsAny
- List.Count
- List.Covariance
- List.Dates
- List.DateTimes
- List.DateTimeZones
- List.Difference
- List.Distinct
- List.Durations
- List.FindText
- List.First
- List.FirstN
- List.Generate
- List.InsertRange
- List.Intersect
- List.IsDistinct
- List.IsEmpty
- List.Last
- List.LastN
- List.MatchesAll
- List.MatchesAny
- List.Max
- List.MaxN
- List.Median
- List.Min
- List.MinN
- List.Mode
- List.Modes
- List.NonNullCount
- List.Numbers
- List.Percentile
- List.PositionOf
- List.PositionOfAny
- List.Positions
- List.Product
- List.Random
- List.Range
- List.RemoveFirstN
- List.RemoveItems
- List.RemoveLastN
- List.RemoveMatchingItems
- List.RemoveNulls
- List.RemoveRange
- List.Repeat
- List.ReplaceMatchingItems
- List.ReplaceRange
- List.ReplaceValue
- List.Reverse
- List.Select
- List.Single
- List.SingleOrDefault
- List.Skip
- List.Sort
- List.Split
- List.StandardDeviation
- List.Sum
- List.Times
- List.Transform
- List.TransformMany
- List.Union
- List.Zip
- Logical.From
- Logical.FromText
In this article, we will explore the M code behind the Lines.ToBinary function and learn how to use it effectively in our Power Query workflows.
Understanding the Lines.ToBinary Function
The Lines.ToBinary function is a built-in function in Power Query that converts a text string into a binary value. The function takes one argument, which is a text string, and returns a binary value.
The syntax for the Lines.ToBinary function is as follows:
Lines.ToBinary(text as text) as binary
In this syntax, the text argument is the text string that we want to convert to binary. The function returns a binary value.
Let's look at an example to understand how the Lines.ToBinary function works. Suppose we have a text string "Hello, world!". We can apply the Lines.ToBinary function to this text string using the following code:
Lines.ToBinary(“Hello, world!”)
This will return the binary value:
01101000 01100101 01101100 01101100 01101111 00101100 00100000 01110111 01101111 01110010 01101100 01100100 00100001
The binary value is a sequence of 0s and 1s that represent the characters in the text string. Each character in the text string is converted to its binary representation, and the binary values for all the characters are concatenated to form the final binary value.
Using the Lines.ToBinary Function in Power Query
Now that we understand the Lines.ToBinary function, let's see how we can use it in Power Query.
Suppose we have a table with a column called "Text" that contains text strings. We want to add a new column to this table that contains the binary values of the text strings in the "Text" column.
We can do this using the following steps:
1. In Power Query, select the table that contains the "Text" column.
2. Click on the "Add Column" tab in the ribbon.
3. Click on the "Custom Column" button.
4. In the "Custom Column" dialog box, enter a name for the new column (e.g. "Binary").
5. In the "Custom Column" dialog box, enter the following formula:
Lines.ToBinary([Text])
6. Click on the "OK" button to create the new column.
This will create a new column in the table called "Binary" that contains the binary values of the text strings in the "Text" column.
The M Code Behind the Lines.ToBinary Function
Now let's take a look at the M code behind the Lines.ToBinary function. Understanding the M code can help us better understand how the function works and how we can modify it to suit our needs.
The M code for the Lines.ToBinary function is as follows:
(text as text) => Binary.FromText(
Text.Combine(
List.Transform(
Text.ToList(text),
each Text.PadStart(
Number.ToText(
Number.FromText(
Text.Upper(
Text.FromUnicode(_)
)
),
8,
“0”
),
8,
“0”
)
),
” “
),
BinaryEncoding.Base2
)
Let's break down this code to understand what it does.
The first line of the code defines the function argument:
(text as text) =>
This tells us that the function takes one argument, which is a text string, and returns a value.
The next line of the code converts the text string to a binary value:
Binary.FromText(
The Binary.FromText function is a built-in function in Power Query that converts a text string to a binary value. The function takes two arguments: the text string to be converted, and the encoding type (in this case, BinaryEncoding.Base2).
The next few lines of the code transform the text string into a list of binary values:
Text.Combine(
List.Transform(
Text.ToList(text),
each Text.PadStart(
Number.ToText(
Number.FromText(
Text.Upper(
Text.FromUnicode(_)
)
),
8,
“0”
),
8,
“0”
)
),
” “
),
Let's break down this code to understand what it does.
The first line of this code converts the text string to a list of characters:
Text.ToList(text),
The List.Transform function is a built-in function in Power Query that transforms a list of values into a new list of values. In this case, the function takes the list of characters in the text string and transforms them into a list of binary values.
The next few lines of code convert each character in the list to its binary value:
Number.FromText(
Text.Upper(
Text.FromUnicode(_)
)
),
8,
“0”
Let's break down this code to understand what it does.
The first line of this code converts the character to its Unicode value:
Text.FromUnicode(_)
The second line of this code converts the Unicode value to uppercase:
Text.Upper(
The third line of this code converts the uppercase Unicode value to a number:
Number.FromText(
The final line of this code converts the number to an 8-bit binary value:
Text.PadStart(
Number.ToText(
Number.FromText(
Text.Upper(
Text.FromUnicode(_)
)
),
8,
“0”
),
8,
“0”
)
The Text.PadStart function is a built-in function in Power Query that pads a text value with a specified character to a specified length. In this case, the function pads the 8-bit binary value with leading 0s to ensure that it is 8 bits long.
Finally, the List.Combine function is used to concatenate all the binary values into a single binary value:
Text.Combine(
List.Transform(
Text.ToList(text),
each Text.PadStart(
Number.ToText(
Number.FromText(
Text.Upper(
Text.FromUnicode(_)
)
),
8,
“0”
),
8,
“0”
)
),
” “
),
The binary values are concatenated with a space character in between each value to form the final binary value.
In this article, we have explored the Lines.ToBinary function in Power Query and learned how to use it to convert text strings to binary values. We have also examined the M code behind the Lines.ToBinary function to better understand how it works and how we can modify it to suit our needs.
The Lines.ToBinary function is a powerful tool in Power Query that can be used to transform text data into binary data. With a better understanding of how the function works, we can use it more effectively in our Power Query workflows.