UNICODE

How to Use the Power BI DAX function UNICODE

What is the DAX Function UNICODE?

DAX stands for Data Analysis Expressions, and it is a formula language used in Power BI to create custom calculations. The UNICODE function in DAX returns the Unicode value of the first character of a text string. Unicode is a computing standard that defines a unique number for every character, symbol, and punctuation mark in the world’s languages. By using the UNICODE function in Power BI, you can convert text into its corresponding Unicode value, making it easier to work with non-standard characters and symbols.

Using the DAX Function UNICODE in Power BI

To use the DAX function UNICODE in Power BI, you can follow these simple steps:

1. Open Power BI Desktop and create a new report.

2. Click on the “New Measure” button in the “Modeling” tab.

3. Enter a name for your measure and start typing the formula using the UNICODE function. For example, you can use the following formula to get the Unicode value of the first character in a text string:


UNICODE(“A”)


4. Replace the letter "A" with the text string you want to convert into its Unicode value.

5. Press Enter to validate the formula and create your new measure.

Once you have created your measure using the UNICODE function, you can use it in your visuals, tables, and charts just like any other measure in Power BI.

Practical Examples of Using the DAX Function UNICODE

Now that you know how to use the DAX function UNICODE in Power BI let's look at some practical examples of how it can be used to solve real-world problems.

Example 1: Converting Currency Symbols to Unicode Values

Let's say you have a table in Power BI that contains different currency symbols, such as "$", "€", "¥", and "£". You want to convert these symbols into their corresponding Unicode values so that you can perform calculations and comparisons based on the currency type.

You can use the following formula to achieve this:


UNICODE(LEFT([Currency], 1))


This formula takes the first character of the currency symbol using the LEFT function and converts it into its Unicode value using the UNICODE function. You can then use this measure in your visuals and tables to display the Unicode values instead of the currency symbols.

Example 2: Removing Non-Standard Characters from Text

Let's say you have a column in your data that contains text strings with non-standard characters, such as emojis, special characters, or foreign language characters. You want to remove these non-standard characters from the text to make it easier to work with.

You can use the following formula to achieve this:


CONCATENATEX(FILTER(VALUES([Text]), UNICODE(LEFT([Text], 1)) ❰ 128), [Text], “”)


This formula uses the FILTER function to remove any non-standard characters from the text string and returns only the ASCII characters (Unicode values less than 128). The CONCATENATEX function is used to combine all the filtered text strings into a single string without any non-standard characters.

The DAX function UNICODE in Power BI is a powerful tool for working with non-standard characters and symbols in your data. By converting text into its corresponding Unicode value, you can perform calculations, comparisons, and filtering with ease. In this article, we have explored what the UNICODE function is, how to use it in Power BI, and some practical examples to demonstrate its effectiveness. With this knowledge, you can take your Power BI reports to the next level and analyze data from all over the world.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

11-13 November 2024

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)