Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Case statement in Tableau

Tableau provides CASE statement to check multiple conditions and provide the conversion values just like SQL case statement.

Example : Checks if the product name length is greater than 10 characters, and get first 10 characters for long product names and for other product it gets the whole product name.
CASE LEN([Product Name]) > 10 
WHEN TRUE THEN MID([Product Name],0,10)
ELSE [Product Name] END


Output
ProductNameDisplayProductName
Phillips AventPhillips A
AppleWatchAppleWatch


Case statement can be extended for multiple else if conditions also. Example
CASE <Expression>
WHEN value1 THEN 'value1 is met'
WHEN value2 THEN 'value2 is met'
ELSE 'Nothing is met' END