Wednesday, June 21, 2023

Explain the String Function ' RIGHT ' in Tableau with Example?

 In Tableau, the RIGHT function is used to extract a specified number of characters from the rightmost portion of a string. It allows you to retrieve a substring consisting of the rightmost characters of a given string.


The syntax for the RIGHT function in Tableau is as follows:


RIGHT(string, length)


  • string is the original string from which you want to extract the rightmost characters.
  • length is the number of characters you want to extract from the right side of the string.


Here's an example to illustrate the usage of the RIGHT function in Tableau:


Let's say we have a dataset with a column called "Order ID," which contains unique identifiers for each order. The order IDs have a consistent format, with a fixed number of characters. We want to extract the last four characters from the "Order ID" column.


Order ID

ORD12345678

ORD98765432

ORD54321678

ORD24681357

To extract the rightmost four characters from the "Order ID" column, we can use the RIGHT function as follows:

RIGHT([Order ID], 4)


The result will be a new column with the extracted substrings:


Order ID                                                                 Extracted ID

ORD12345678                                                 5678

ORD98765432                                                 5432

ORD54321678                                                 1678

ORD24681357                                                 1357


In this example, the RIGHT function extracts the rightmost four characters from the "Order ID" column. As a result, we obtain a new column called "Extracted ID" that contains the extracted substrings.


It's important to note that if the specified length exceeds the available characters from the right side of the string, the function will return the entire string.


The RIGHT function in Tableau is particularly useful when dealing with strings that have a consistent structure or format, and you need to extract specific information from the rightmost portion of the string.

No comments:

Post a Comment

If you have any doubts. Please let me know

How can you create an alias for a table in a SQL query?

In SQL, you can create an alias for a table in a query to give the table a temporary, alternative name that you can use in the query. Table ...