Question

setting Case statement on yesno dimension that will work in user_details drill down

  • 16 July 2020
  • 2 replies
  • 1284 views

I have a yesno dimension that I need to read as a string. ex. case when x = “no” then “send” when x = "yes then “keep”

if I create a string dimension with case statement, it will not work in user_details drill down. Do I need to Cast something to make this work?


2 replies

Userlevel 5
Badge

Hello @bohonkus and welcome!


From what I gather you have two options



  • If you’re using the LookML substitution syntax (preferred)


dimension: your_yesno_dimension {
type: yesno
sql: ${TABLE}.your_yesno_column ;;
}

dimension: yesno_string {
type: string
sql:
case
when ${your_yesno_dimension} then 'send'
else 'keep'
end
;;
}


  • If you’re using the raw column name


dimension: yesno_string {
type: string
sql:
case
when ${TABLE}.your_yesno_column then 'send'
else 'keep'
end
;;
}

this worked, thank you!

Reply