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

jhalfon
Participant I

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?

0 2 2,195
2 REPLIES 2

Hello @jhalfon 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
  ;;
}

jhalfon
Participant I

this worked, thank you!

Top Labels in this Space
Top Solution Authors