Monday, June 19, 2023

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

 In Tableau, the "ENDSWITH" function is used to check if a given string ends with a specific substring. It returns a Boolean value of "True" if the specified string ends with the provided substring, and "False" otherwise.


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

ENDSWITH(string, substring)


Here, "string" is the original string you want to check, and "substring" is the string you are checking if it is at the end of the original string.


Let's consider an example to understand the usage of the ENDSWITH function:


Suppose we have a dataset of email addresses, and we want to identify the email addresses that end with ".com". We can use the ENDSWITH function to accomplish this.


  • Create a calculated field by right-clicking on a blank area in the "Data" pane and selecting "Create Calculated Field."
  • In the calculation editor, enter the following formula:

            ENDSWITH([Email], ".com")

            Here, [Email] is the field containing the email addresses, and ".com" is the substring we want to             check if it appears at the end of the email addresses.


  • Provide a name for the calculated field, such as "EndsWithCom," and click on the "OK" button.
  • You can now use the "EndsWithCom" field in your analysis. Drag and drop it onto the filter shelf to filter the data based on the result of the ENDSWITH function.


For example, if you want to display only the email addresses that end with ".com," you can set the "EndsWithCom" filter to "True."


The ENDSWITH function will return "True" for email addresses like "example@example.com," "info@company.com," "john.doe@email.com," etc., and "False" for email addresses that don't end with ".com."


By using the ENDSWITH function in Tableau, you can perform various string matching and filtering operations based on the endings of strings in your data.


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 ...