Editor Case Function with LIKE or startWith

Hi,

can I use the case function with other fuctions, e.g. startsWith or LIKE in the editor?

Use Case: Create a custom column with a location name based on the printer prefix.

Device Names:

ABXXXX01 = Location A
ABXXXX02 = Location A
ABXXXX99 = Location A

CDXXXX01 = Location B
CDXXXX01 = Location B
CDXXXX99 = Location B

case function in the editor only works with the operator = (so I'd need to include all 99 devices per location, which would obviously a pain)

image

Hi @germanprinter
Have a look here to learn the syntax: https://www.metabase.com/docs/latest/questions/query-builder/expressions-list#startswith

case(startsWith([T Device], "AB"), "Location A", "Location B")

Awesome. If there is more than two Option (Device Names) A and B, how would I set up this?

The current option shows only if the device name starts with AB then Location A else Loaction B

but what if there was Device Name , A & B & n , Else x?

image

@germanprinter Have a look at the case() documentation:
https://www.metabase.com/docs/latest/questions/query-builder/expressions/case