Forum Discussion
Create Column
- 6 years ago
Well, that's frankly a horrible construction, doesn't Tableau have a SWITCH/CASE statement?
Use a SWITCH(TRUE()...) statement. Replace CONTAINS with SEARCH or FIND like:
Column?
SWITCH(TRUE(),
SEARCH("AIX 5.3",[OS],,-1 ) <> -1 THEN "AIX 5.3",
SEARCH("AIX 6.1",[OS],,-1 ) <> -1 THEN "AIX 6.1",
...
)
Well, that's frankly a horrible construction, doesn't Tableau have a SWITCH/CASE statement?
Use a SWITCH(TRUE()...) statement. Replace CONTAINS with SEARCH or FIND like:
Column?
SWITCH(TRUE(),
SEARCH("AIX 5.3",[OS],,-1 ) <> -1 THEN "AIX 5.3",
SEARCH("AIX 6.1",[OS],,-1 ) <> -1 THEN "AIX 6.1",
...
)
They probably don't need the <> -1, only SEARCH statements should do because they return blank if not found to be considered FALSE so, save yourself some writing. So
Column?
SWITCH(TRUE(),
SEARCH("AIX 5.3",[OS]) THEN "AIX 5.3",
SEARCH("AIX 6.1",[OS]) THEN "AIX 6.1",
...
)
- phaering6 years agoHelper I
How do I write a formula where I can hit <ENTER> so I can have one row per "search"? When I try to create a column it seems like I am being limited to writing the entire formula on one line. Thank you!
- Greg_Deckler6 years agoCommunity Champion
Use Alt-Enter
- phaering6 years agoHelper I
I created a quick sample of my entire script and received an error message: "Function 'SWITCH' does not support comparing values fo type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."
I have no idea what this means or how to fix it.
Thank you!