How do I write the equivalent of “if tutor ID appears in list, yes, otherwise no”?
Sort of like if(tutor.id=list(5237, 8296, 4251),yes,no) but something that actually works! In other words, if the tutor id is any one of those three numbers, yes, otherwise no
Hi, I would use the contains, substring or position functions to see if your value appears in the list, comparing one by one using OR is ok if you only have say…3 values. To be accurate you will want to compare your value with a , at the start and end to make sure its not a substring of a larger string (or number in this case) inside the list. So make sure you append a , at the start and end of your list as well: concat(",",list(123,456,789),",")
There’s also a lesser-known function called matches_filter, which I believe is currently only possible in custom fields + custom filters (ie: not table calculations), but it basically lets you use the same filter expressions you’d use in a “matches advanced” type filter—
izzy, thank you so much - two other great methods from Andy and Ian too, but ultimately I went with yours for it’s simplicity, and also I need to be able to use it in custom dimensions. Brilliant! Thanks to Andy and Ian too
I have a similar thing I want to do - but Looker can only do a AND/OR operator with 2 expressions. I dont know if this was an update at some time.
So you can’t do : if(substring(${stage.name},1,2) = “PL” or ${stage.name} = “PreLegal” or ${stage.name} = “Caveat”, “Pre Legal”, “Normal”)
I am putting this in LookML, but it is a pity the AND/OR operator is so limited.