Logical.ToText is a Power Query M function that creates a text value from a logical value, either “true” or “false”. The function returns the created text value or throws an exception if the input is not a logical value.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Logical.ToText( logicalValue as nullable logical ) as nullable text
Description
The Logical.ToText function converts boolean values (true
or false
) into their corresponding text representations (“true” or “false”). If the input is null
, it returns null
, and any non-boolean input results in an error.
Examples
Let’s look at some examples of how the Logical.ToText function works.
Converting Boolean to Text
The Logical.ToText function converts the boolean value true
to the text “true”:
Logical.ToText(true) // Output: "true"
Similarly, it converts the boolean value false
to the text “false”:
Logical.ToText(false) // Output: "false"
Handling Null Values
If the input is null
, the function will return null
:
Logical.ToText( null ) // Output: null
Handling Non-Boolean Inputs
When the input is not a boolean value, the function results in an error. Here are some examples of invalid inputs:
// Output: Expression.Error: We cannot convert the value x to type Logical.
Logical.ToText(1)
Logical.ToText("yes")
Related functions
Other functions related to Logical.ToText are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy