CASE Payment Type
WHEN "CC" THEN "Credit Card"
WHEN "DC" THEN "Debit Card"
WHEN "GC" THEN "Gift Card"
WHEN "CA" THEN "Cash"
ELSE "Other"
END
Syntax
CASEinput_expressionWHENexpression_to_matchTHENresult[WHENexpression_to_matchTHENresult]
[...]
[ELSEelse_result]
END
Parameters
input_expression- Any valid field or expression.
[expression_to_match- Any valid field or expression. TheWHENclause comparesinput_expressiontoinput_expressionand returns true if the two are equal, or false if they aren't.]{#when-conditions}
result- Any valid field or expression. EachWHENclause must have a matchingTHENclause, which specifies the results to return if that condition is true. If there are multipleWHENclauses, theCASEstatement returns the result for the first true clause.
else_result(optional) - Any valid field or expression. TheELSEelse_resultclause specifies a default result for theCASEstatement. This clause is returned if none of theWHENclauses are true. If aCASEstatement has noELSEclause, and none of theWHENclauses are true, theCASEstatement returnsNULL.
How simpleCASEworks
A simpleCASEstatement consists of the following elements:
TheCASEkeyword, followed by an input expression.
WHEN: the value against which to compare theinput_expression: if the value equals theinput_expression, then this clause is true. You can have multipleWHENclauses in a singleCASEstatement.
THEN: the result to return if theWHENclause's condition is true. You must have oneTHENclause for eachWHENclause in yourCASEstatement.
ELSE: Optional. If none of theWHENclause conditions are true,CASEreturns the value in theELSEclause, orNULLif noELSEclause is specified.
TheENDkeyword.
CASEevaluates each successiveWHENclause and returns the first result where the condition is true. Any remainingWHENclauses and theELSEresult are not evaluated. If allWHENconditions are false orNULL,CASEreturns theELSEresult, or if noELSEclause is present, returnsNULL.
Example
Provide customized links for your premium customers:
CASE Premium Status
WHEN "Platinum" THEN CONCAT(Site URL, "platinum_welcome.html")
WHEN "Gold" THEN CONCAT(Site URL, "gold_welcome.html")
WHEN "Silver" THEN CONCAT(Site URL, "silver_welcome.html")
ELSE CONCAT(Site URL, "welcome.html")
END
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["CASE (simple)\n=============\n\nSimple `CASE` returns a result based on the value of a single input expression, or a default result if none of the comparison values match.\n| **Note:** There are two forms of the `CASE` statement: *searched* `CASE` and *simple* `CASE`. Searched `CASE` statements allow you to use more sophisticated logic, while simple `CASE` statements are simpler to construct.\n\nSee also: [IF](/looker/docs/studio/if).\n\nSample usage\n------------\n\nReplace payment codes with intuitive names: \n\n```\n CASE Payment Type\n WHEN \"CC\" THEN \"Credit Card\"\n WHEN \"DC\" THEN \"Debit Card\"\n WHEN \"GC\" THEN \"Gift Card\"\n WHEN \"CA\" THEN \"Cash\"\n ELSE \"Other\"\n END\n```\n\nSyntax\n------\n\n```\n CASE input_expression\n WHEN expression_to_match THEN result\n [WHEN expression_to_match THEN result]\n [...]\n [ELSE else_result]\n END\n```\n\n### Parameters\n\n- \u003cvar translate=\"no\"\u003einput_expression\u003c/var\u003e - Any valid field or expression.\n- \\[\u003cvar translate=\"no\"\u003eexpression_to_match\u003c/var\u003e - Any valid field or expression. The `WHEN` clause compares \u003cvar translate=\"no\"\u003einput_expression\u003c/var\u003e to \u003cvar translate=\"no\"\u003einput_expression\u003c/var\u003e and returns true if the two are equal, or false if they aren't.\\]{#when-conditions}\n- \u003cvar translate=\"no\"\u003eresult \u003c/var\u003e - Any valid field or expression. Each `WHEN` clause must have a matching `THEN` clause, which specifies the results to return if that condition is true. If there are multiple `WHEN` clauses, the `CASE` statement returns the result for the first true clause.\n- \u003cvar translate=\"no\"\u003eelse_result\u003c/var\u003e (optional) - Any valid field or expression. The `ELSE` *else_result* clause specifies a default result for the `CASE` statement. This clause is returned if none of the `WHEN` clauses are true. If a `CASE` statement has no `ELSE` clause, and none of the `WHEN` clauses are true, the `CASE` statement returns `NULL`.\n\n| **Note:** All of the `THEN` clauses in a `CASE` statement must return the same type of result. For example, if the first `THEN` clause returns the **Text** data type, additional `THEN` clauses must also return the **Text** data type.\n\nHow simple `CASE` works\n-----------------------\n\nA simple `CASE` statement consists of the following elements:\n\n- The `CASE` keyword, followed by an input expression.\n- `WHEN` : the value against which to compare the \u003cvar translate=\"no\"\u003einput_expression\u003c/var\u003e : if the value equals the \u003cvar translate=\"no\"\u003einput_expression\u003c/var\u003e, then this clause is true. You can have multiple `WHEN` clauses in a single `CASE` statement.\n- `THEN` : the result to return if the `WHEN` clause's condition is true. You must have one `THEN` clause for each `WHEN` clause in your `CASE` statement.\n- `ELSE` : Optional. If none of the `WHEN` clause conditions are true, `CASE` returns the value in the `ELSE` clause, or `NULL` if no `ELSE` clause is specified.\n- The `END` keyword.\n\n`CASE` evaluates each successive `WHEN` clause and returns the first result where the condition is true. Any remaining `WHEN` clauses and the `ELSE` result are not evaluated. If all `WHEN` conditions are false or `NULL`, `CASE` returns the `ELSE` result, or if no `ELSE` clause is present, returns `NULL`.\n\nExample\n-------\n\nProvide customized links for your premium customers: \n\n```\n CASE Premium Status\n WHEN \"Platinum\" THEN CONCAT(Site URL, \"platinum_welcome.html\")\n WHEN \"Gold\" THEN CONCAT(Site URL, \"gold_welcome.html\")\n WHEN \"Silver\" THEN CONCAT(Site URL, \"silver_welcome.html\")\n ELSE CONCAT(Site URL, \"welcome.html\")\n END\n```\n\nRelated resources\n-----------------\n\n- [Calculated fields](/looker/docs/studio/about-calculated-fields)\n- [Looker Studio function list](/looker/docs/studio/function-list)"]]