Character.FromNumber is a Power Query M function that returns the character equivalent of a given number.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Character.FromNumber( number as nullable number ) as nullable text
Description
Character.FromNumber translates a numeric input into its corresponding unicode character. You supply a number (which can be null), and the function returns its unicode character equivalent, according to the Unicode standard. A null value is returned if the input is null.
Examples
To illustrate the functionality of the Character.FromNumber operation, let’s take the number 9. When you feed this into the function, like so:
Character.FromNumber( 9 ) // Output: "#(tab)"
The result would be “#(tab)”, the character representation of the number 9. Knowing how to use this isn’t as useful by itself, but let’s see an area where this is more useful in the context of lists.
One intriguing aspect of this function is its interaction with the ‘a..b’ construct in list generation. This construct leverages Unicode values, the universal character encoding standard. For instance:
{ "a" .. "g" } // Returns { "a", "b", "c", "d", "e", "f", "g" }
Here’s what’s happening under the hood:
Character.ToNumber( "a" ) // Returns 97, the Unicode value for 'a'.
Character.ToNumber( "g" ) // Returns 103, the Unicode value for 'g'.
The list generation happens based on the underlying unicode characters.
This concept becomes even more evident when generating a series from ‘Z’ to ‘\’. Power Query, following the order of the Unicode values, delivers the following:
{ "Z" .. "\" } // Returns { "Z", "[", "\" }
Character.ToNumber( "Z" ) // Output: 90
Character.ToNumber( "[" ) // Output: 91
Character.ToNumber( "\" ) // Output: 92
In summary, the Character.FromNumber function in Power Query M provides a systematic way to convert numeric inputs into their respective character equivalents. Understanding this functionality helps in converting numbers into their unicode characters or the other way around.
Related articles
Learn more about Character.FromNumber in the following articles:
- Generating Random Numbers in Power Query
Generate random numbers, letters, dates, & symbols in Power Query. Find out how to prevent duplicates & generate lists of random values. » Read more - Creating Sequences in Power Query
Create Sequences in Power Query and Simplify your Code. Learn how to generate series of numbers, text, symbols, and dates with simple functions. » Read more - Lists in Power Query M / List Functions (200+ Examples)
The complete guide to Lists in Power Query M. Learn from practical examples and master Power Query’s most powerful List functions. » Read more - Text Functions in Power Query M (150+ Examples)
Your guide to Text Functions in Power Query M. Learn from practical examples and master Power Query’s most useful Text functions. » Read more
Related functions
Other functions related to Character.FromNumber are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy