10 Important String Functions in Tableau - CNDRO.LLC
1851
post-template-default,single,single-post,postid-1851,single-format-standard,wp-custom-logo,theme-bridge,bridge-core-2.9.4,woocommerce-no-js,tribe-no-js,ehf-template-bridge,ehf-stylesheet-bridge-child,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,columns-4,qode-child-theme-ver-1.0.0,qode-theme-ver-27.8,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.7.0,vc_responsive,elementor-default,elementor-kit-2634

10 Important String Functions in Tableau

In Tableau, strings or string data, are data made of text. String functions exist to help you manipulate your string data. There about twenty string functions in Tableau. In this article, I am going to introduce you to ten (10) important string functions in Tableau, and how to use them.

You might be wondering “why are string functions so important?” Let’s assume a scenario where you want to pull the first name of all your customers into a new field; a string function will handle that task for you.

String Functions In Tableau

Important String Functions in Tableau

Please note that all the string functions in Tableau are of extreme importance. This article is just exploring 10 of them, and they include:

  1. ASCII
  2. CONTAINS
  3. FIND
  4. LEFT
  5. LEN
  6. MID
  7. REGEXP_MATCH
  8. REGEXP_REPLACE
  9. SPLIT
  10. TRIM

1. ASCII

This returns the ASCII code value of the first character in a string

ASCII ( String )

ASCII (“authors”) = 97

2. CONTAINS

This returns a TRUE if the specified substring is present in the given string.

CONTAINS ( String, Substring )

CONTAINS (“Calculation” , “alcu”)

3. FIND

This returns the position of the specified substring within the given string and returns 0 if the substring is not found.

FIND (String, Substring, [ Start ])

The first character in the string is position 1 (not a 0 index).

FIND (“Calculation”, “alcu”) = 2

If the start argument is defined, any instance of the substring that appears before the start position are ignored

FIND (“Calculation”, “a”, 3 ) = 7

4. LEFT

LEFT ( Stringnum_chars)

This returns the specified number of characters from the start of the given string.

LEFT (“Calculation”, 5 ) = “Calcu”

5. LEN

LEN (String)

This returns the number of characters in the given string.

LEN (“Calculation”) = 11

6. MID

MID (String, Start, [length])

This returns the characters from the middle of a text string given a starting position and a length. The first character in the string is in position 1. If the length is not included, all characters to the end of the strings are not returned.

MID (“Tableau Software”,  9 ) = “Software”

If the length is included, up to that many characters are returned.

MID (“Tableau Software”, 2, 4) = “able”

7. REGEXP_MATCH

REGEXP_MATCH ( String , Pattern )

This returns true if a substring of the provided string matches the regular expression pattern.

REGEXP_MATCH ( ‘ - ( [1234] . [ The.Market] ) -’ ,  ‘\ [\s*(w*\.)  (  \w*\s*\]) ‘ ) = true

8. REGEXP_REPLACE

REGEXP_REPLACE ( String, Pattern, replacement)

This returns a copy of a given string where the matching pattern is substituted with the replacement string.

REGEXP_REPLACE ( ‘abc123’, ‘\s’, ‘-’ ) = ‘abc--123’

9. SPLIT

SPLIT ( String , delimiter, token number)

This returns a substring from a string as determined by a delimiter (a separator) extracting the characters from the beginning or end of the string.

SPLIT (‘a/b/c/d’ , ‘ / ‘ , 2 ) = ‘b’

A negative token number can also be used.

SPLIT (‘a/b/c/d’ , ‘ / ‘ ,  -2 ) =  ‘c’

10. TRIM

TRIM (String)

This returns the string with both leading (LTRIM is used for this only ) and trailing (RTRIM is used for this only ) whitespaces removed.

TRIM (“  Budget   ”)  =  “Budget”

To learn more about all the string functions in tableau, click here.

No Comments

Post A Comment