Looker Case When Table Calculations

I’m trying to extract New York City borough from a full address field. I want a new custom field that has borough values: Brooklyn, Manhattan, Bronx, etc. I tried doing the following but I’m getting an incomplete expression. I have a user license so I would need to do this in table calculations. Thank you

if(contains(${contact.address}, “Bronx”,“Bronx”) = “Bronx”
OR
contains(${contact.address},“Brooklyn”) = “Brooklyn”
OR contains(${contact.address},“Manhattan”) = “Manhattan”) yes,null)

There are a couple syntax errors in your custom field logic, but ultimately it’s probably easier to use the case statement, like this rather than nested if statements:

case(

 when(contains(${contact.address}, "Bronx"),"Bronx")

,when(contains(${contact.address}, "Brooklyn"),"Brooklyn")

,when(contains(${contact.address}, "Manhattan"),"Manhattan")

,null

)
3 Likes

Thank you, @Ben_Zitney ! Appreciate your help! It works!

case(

when(contains(${contact.address}, “Bronx” ), “Bronx”)

,when(contains(${contact.address}, “Brooklyn” ), “Brooklyn”)

,when(contains(${contact.address}, “Manhattan” ), “Manhattan”)

,null)