Looker Case When Else return original values

Hi 

I have a column contains multiple values, (eg: 0, 1, 2, 3, ..., 200), and I want to show 0 as "No item" and the rest of value stays the same.  I try using case when to reach this goal but I not want to hard code 1 ~ 200 in when statement. 
Is there anyway make "else:" can return the original values from the column ?
Thank you

Example: 
dimension: column{
case: {
when: {
sql: ${TABLE}.column= 0 ;;
label: "No item"
}
else: ?
}
sql: ${TABLE}.column;;
}

Solved Solved
0 1 31
1 ACCEPTED SOLUTION

It sounds like you're trying to change the dimension value for Column and not group the results.

If that is the case, we typically put the case statement within the sql clause of the column. Syntax may vary slightly based on your database.

Depending on your use case, you may have some things to address since Column contains numeric values, but you want to replace the value of 0 with a string.
Hope that helps!
-BW

dimension: column {
    type: string
    label: "Column Name"
    sql: CASE
          WHEN ${TABLE}."COLUMN" = '0' THEN 'No Item'
          WHEN ${TABLE}."COLUMN" = '1' THEN 'Another Special Item'
          ELSE ${TABLE}."COLUMN"
         END ;;
  }




View solution in original post

1 REPLY 1

It sounds like you're trying to change the dimension value for Column and not group the results.

If that is the case, we typically put the case statement within the sql clause of the column. Syntax may vary slightly based on your database.

Depending on your use case, you may have some things to address since Column contains numeric values, but you want to replace the value of 0 with a string.
Hope that helps!
-BW

dimension: column {
    type: string
    label: "Column Name"
    sql: CASE
          WHEN ${TABLE}."COLUMN" = '0' THEN 'No Item'
          WHEN ${TABLE}."COLUMN" = '1' THEN 'Another Special Item'
          ELSE ${TABLE}."COLUMN"
         END ;;
  }




Top Labels in this Space