Knowledge Drop

CASE WHEN in table calcs


Userlevel 5
Badge
  • Looker Staff
  • 173 replies

Last Tested: March 22, 2021

Though a case when in table calcs is currently a feature request (see https://feedback.us.pendo.io/app/#/case/32191), you can make it work with nested if statements. If you use coalesce, it becomes even more readable:

coalesce(
if(${field} < 1, "Less than 1", null),
if(${field} =< 2, "1 - 2", null),
if(${field} =< 3, "2 - 3", null),
if(${field} =< 4, "3 - 4", null),
if(${field} =< 5, "4 - 5", null),
"More than 5")

 

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply