Character.FromNumber

Updated on

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.

Learn more about Character.FromNumber in the following articles:

Other functions related to Character.FromNumber are:

Last update: December 17, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/character-fromnumber
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy