Facebook
From Scorching Giraffe, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 98
  1. dimension: have_paid {
  2.     type: number
  3.     sql: CASE
  4.       WHEN ${user_pay} = 0 THEN 0
  5.       WHEN ${user_pay} !=0 THEN 1
  6.       ELSE NULL
  7.       END
  8.       ;;
  9.   }
  10.   dimension: type {
  11.     hidden: yes
  12.     sql:
  13.       CASE
  14.         WHEN ${have_paid} = 0 AND ${user_id_source1} IS NOT NULL THEN "FREE"
  15.         WHEN ${have_paid} > 0 AND ${user_id_source1} IS NOT NULL THEN "PAIDE"
  16.         WHEN ${have_paid} = 0 AND ${user_id_source2} IS NOT NULL THEN "NOT PAID"
  17.         ELSE "na"
  18.       END;;
  19.   }
  20.  dimension: d_a {
  21.     label: "dim A"
  22.     type: string
  23.     sql:
  24.       CASE
  25.       WHEN ${type} = "FREE"
  26.         THEN ${user_id_source2}
  27.       ELSE null
  28.       END;;
  29.   }
  30.   dimension: d_b {
  31.     label: "dim B"
  32.     type: string
  33.     sql:
  34.     CASE
  35.     WHEN ${type} = "PAID"
  36.       THEN ${user_id_source2}
  37.     ELSE null
  38.     END;;
  39.   }
  40.   dimension: d_c {
  41.     label: "dim C"
  42.     type: string
  43.     sql:
  44.     CASE
  45.     WHEN ${type} = "NOT PAID"
  46.       THEN ${user_id_source2}
  47.     ELSE null
  48.     END;;
  49.   }
  50.   measure: m_a {
  51.     label: "meas a"
  52.     type: count_distinct
  53.     sql: ${d_a} ;;
  54.   }
  55.   measure: m_b {
  56.     label: "meas b"
  57.     type: count_distinct
  58.     sql: ${d_b};;
  59.   }
  60.   measure: m_c {
  61.     label: "meas c"
  62.     type: count_distinct
  63.     sql: ${d_c}  ;;
  64.   }