> For the complete documentation index, see [llms.txt](https://concentra-analytics.gitbook.io/working-with-data/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://concentra-analytics.gitbook.io/working-with-data/logical/case_switch.md).

# Case / Switch

## Excel

Excel doesn't support a specific case function but instead use an IF...ELSE statement \
&#x20;\=\~IF!\~(‹logical\_test1›, ‹when\_true1›, \~IF!\~(‹logical\_test2›, ‹when\_true2›, ‹when\_false2›))

```
=IF(C10 = "A", 1, IF(C10 = "B", 2, IF(A1 = "C", 3,0)))
```

## Tableau

\~CASE!\~ ‹field› \~WHEN!\~ ‹condition1› \~THEN!\~ ‹return1› «WHEN condition2 THEN return2 ... » \~ELSE!\~ ‹returnN› \~END.\~

```
CASE [Job Band] 
  WHEN "A" THEN 1 
  WHEN "B" THEN 2 
  WHEN "C" THEN 3 
END
```

NB. Each `WHEN` tests the *actual string* provided and compares it to the value of the target field; it does not allow logical tests e.g. `WHEN > 10 ...`. For this, use an IF...ELSE statement.

## Alteryx

\~SWITCH!\~(‹field›, ‹default\_result›, ‹condition1›, ‹return1›«, condition2, return2, ...»)

```
SWITCH([Job Band], 0, 
  "A", 1, 
  "B", 2, 
  "C", 3
)
```

## OrgVue

‹var expression› = {‹condition1›: ‹return1›«, condition2: return2, ... »}; \
&#x20;‹expression›\[‹node.field›]

```
var gradeMap = {
   "A": 1,
   "B": 2,
   "C": 3,
};
node.gradeMap[node.jobband]
```

## tSQL

\~CASE!\~ «(field)» \~WHEN!\~ ‹condition1› \~THEN!\~ ‹return1› \~ELSE!\~ ‹return2› \~END!\~

```
SELECT CASE(JobBand)
 WHEN "A" THEN 1
 WHEN "B" THEN 2
 WHEN "C" THEN 3
AS Grade
FROM EmployeesData
```

NB. If you omit the «field», the `CASE` statement will search all fields.

```
CASE
WHEN MIN(Value) <= 0 THEN 0 
WHEN MAX(Value) >= 100 THEN 1 
END
```

## Python

‹var expression› = {‹condition1›: ‹return1›,« condition2: return2, ...»}; \
&#x20;‹expression›\[‹field›]

```
gradeMap = {
   "A": 1,
   "B": 2,
   "C": 3,
};
gradeMap[jobBand]
```

NB. The above example assumes a variable has been declared for `jobBand`. For more information, go to [General > Variables](https://orgvue.gitbooks.io/formula-translator/content/general/variables.html).
