how to make case dimensions out of a column?

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
0 1 101
1 REPLY 1

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”

7642d778-dae3-403c-917d-8305659141e1.png

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

Top Labels in this Space
Top Solution Authors