how will I convert this sql into explore script to create dimension in looker?
[Note : here table_recommendation , Markup and Markup are column names in Bigquery]
Solved! Go to Solution.
Looker does not have a direct parameter to enable the case statements, however we can always make use of SQL parameter in dumenisons in such scenarios. Please see below:
dimension: country {
type: string
sql: CASE WHEN ${TABLE}.COUNTRY = 'UK' THEN 'United Kingdom'
WHEN ${TABLE}.COUNTRY = 'UAE' THEN 'United Arab Emirates'
ELSE ${TABLE}.COUNTRY END ;;
}
Also the type in your case will be string and not number.
Hope this helps.
~Ashish
Looker does not have a direct parameter to enable the case statements, however we can always make use of SQL parameter in dumenisons in such scenarios. Please see below:
dimension: country {
type: string
sql: CASE WHEN ${TABLE}.COUNTRY = 'UK' THEN 'United Kingdom'
WHEN ${TABLE}.COUNTRY = 'UAE' THEN 'United Arab Emirates'
ELSE ${TABLE}.COUNTRY END ;;
}
Also the type in your case will be string and not number.
Hope this helps.
~Ashish
IT works for me .Thanks for the solution:)