Does someone know how I can use this type of sql in Looker?
Select
, count(case when tickets= 'A' then id end) as a_tickets
, count(case when tickets= 'B' then id end) as b_tickets
from tickets
original table is something like this--
id | tickets |
---|---|
ghja | A |
ghfd | A |
adfd | B |
dfsr | B |
mndf | B |
Output--
a_tickets | b_tickets |
2 | 3 |
You can use Custom Measure for this
You would select ${id} as the dimension to count, type count_distinct and in the filter you could put
${tickets} = “A”
You need to have access to Custom Fields (enable them as they’re still in beta). In the next version, i.e., 21.8 the UI will change slightly but you can refer to this page for more information:
https://docs.looker.com/exploring-data/adding-fields/custom-measure