Dax Function: UNICODE
Category: Text Functions
The UNICODE function in Power BI is a DAX (Data Analysis Expressions) function that returns the numeric Unicode value of the first character in a given text string. Unicode is a standardized character encoding system that assigns a unique numeric code to every character, including letters, symbols, and emojis.
Purpose
Character Identification: Extract the Unicode value of characters in a text string.
Data Analysis: Identify and process specific characters in datasets.
Localization Support: Work with multilingual data by analyzing Unicode codes.
Type of Calculations
The function performs a scalar transformation by mapping the first character of a text string to its corresponding Unicode numeric value.
Practical Use Cases
Data Cleaning: Identify and filter out non-standard characters.
Custom Sorting: Sort datasets based on the Unicode values of text.
Character Mapping: Map symbols or letters to their corresponding Unicode values for transformations or categorization.
Multilingual Data Support: Analyze text data from multiple languages.
UNICODE(<text>)</text>
| Parameter | Type | Description |
|---|---|---|
| text | Text/Scalar | The text string from which the Unicode value is extracted. |
How Does UNICODE Dax Function Works
Input Text: The function accepts a single text string.
Extract First Character: It isolates the first character in the string.
Map to Unicode: It retrieves the numeric Unicode value corresponding to this character.
Return Numeric Value: The function outputs this numeric value.
For example:
Input:
"A"Output:
65(Unicode for ‘A’).
What Does It Return?
The function returns a numeric value representing the Unicode code of the first character in the provided text string.
When Should We Use It?
Text Analysis: Analyze datasets containing multilingual text or symbols.
Character Filtering: Remove or transform specific characters based on their Unicode values.
Custom Encoding: Create mappings between characters and numeric codes for further processing.
Examples
Basic Usage :
UNICODE("A")
Result: 65
Column Usage:
Extract Unicode values for the first character of each entry in a column:
UnicodeValue = UNICODE(Table[ColumnName])
Input:
"Hello","Data","😀"Output:
72(H),68(D),128512(😀).
Dynamic Categorization:
Group entries based on Unicode ranges:
CharacterGroup =
SWITCH(
TRUE(),
UNICODE(Table[ColumnName]) >= 65 && UNICODE(Table[ColumnName]) <= 90, "Uppercase Letters",
UNICODE(Table[ColumnName]) >= 97 && UNICODE(Table[ColumnName]) <= 122, "Lowercase Letters",
"Other"
)
Output: Categorizes entries based on their first character.
Combine with Other Functions:
Identify non-standard characters:
IsStandardCharacter = IF(UNICODE(Table[ColumnName]) < 128, "Standard", "Non-Standard")
Output: Flags non-ASCII characters.
Tips and Tricks
Check Unicode Tables: Use online Unicode reference tables to identify specific character codes.
Handle Empty Strings: Ensure the input text is not empty; otherwise, the function may return an error.
Focus on First Character: The function only processes the first character in the text string.
Performance Impact of UNICODE DAX Function:
Scalable for Columns: Efficient when applied to individual rows in a calculated column.
Pre-Filter Data: Filter datasets to avoid unnecessary calculations on irrelevant rows.
Related Functions You Might Need
UNICHAR: Converts a numeric Unicode value back into its corresponding character.
CODE: Returns the ASCII code for the first character in a string (limited to ASCII range).
LEFT: Extracts the first character in a string for further analysis.
Want to Learn More?
For more information, check out the official Microsoft documentation for UNICODE You can also experiment with this function in your Power BI reports to explore its capabilities.
Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.
It returns the Unicode numeric value of the first character in a text string.
Yes, it works with characters from various languages, including symbols and emojis.
The function returns an error if the text string is empty.
No, it supports the full range of Unicode characters.
UNICODE works with the full Unicode range, while CODE is limited to the ASCII range.