RIGHT Function in Power BI

How To Use the RIGHT Function in Power BI

Have you ever needed to extract a length of characters from the right of some text, or wanted to get the last word after the last space from the right of some text? Good news! Power BI has a built-in function named RIGHT. This function takes a column and extracts characters from the right based on the number the is passed as a parameter.

What Is the RIGHT Function?

The RIGHT function is a built-in DAX function within Power BI that allows you to extract a number of characters from the right of a column.

RIGHT Function Syntax

This DAX function has a simple syntax. The RIGHT function can be used like the below.

=RIGHT(<text>, <num_chars>) 

Parameters

TermDefinition
textThe text string that contains the characters you want to extract, or a reference to a column that contains text.
num_chars(optional) The number of characters you want RIGHT to extract; is omitted, 1. You can also use a reference to a column that contains numbers.

The reference column will be casted as text if it does not contain text.

How To the RIGHT Function?

Now that we know what the RIGHT function is and what it is used for, let’s see how we can use it.

In Power BI, create a new report and import a dataset that contains text. I have a sample dataset that I have created in Power BI.

test data in power bi

Created a calculated column and use the RIGHT function syntax as described above. I have passed a column that contains text and the ‘num_chars’ as 3, and I now have the below.

RIGHT Function in Power BI

You will see that I now have a column that contains the last 3 characters of the text in column ‘Sentence’. But what will happen if we don’t specify that number of characters?

By default, Power BI will take the last character of text if you do not specify a number. For example, if you just write =RIGHT(Sentences[Sentence]), Power BI will return the last character of the ‘Sentences[Sentence]’ column.

Function in Power BI example

To learn more please visit Learn DAX

Similar Posts