dimension: have_paid { type: number sql: CASE WHEN ${user_pay} = 0 THEN 0 WHEN ${user_pay} !=0 THEN 1 ELSE NULL END ;; } dimension: type { hidden: yes sql: CASE WHEN ${have_paid} = 0 AND ${user_id_source1} IS NOT NULL THEN "FREE" WHEN ${have_paid} > 0 AND ${user_id_source1} IS NOT NULL THEN "PAIDE" WHEN ${have_paid} = 0 AND ${user_id_source2} IS NOT NULL THEN "NOT PAID" ELSE "na" END;; } dimension: d_a { label: "dim A" type: string sql: CASE WHEN ${type} = "FREE" THEN ${user_id_source2} ELSE null END;; } dimension: d_b { label: "dim B" type: string sql: CASE WHEN ${type} = "PAID" THEN ${user_id_source2} ELSE null END;; } dimension: d_c { label: "dim C" type: string sql: CASE WHEN ${type} = "NOT PAID" THEN ${user_id_source2} ELSE null END;; } measure: m_a { label: "meas a" type: count_distinct sql: ${d_a} ;; } measure: m_b { label: "meas b" type: count_distinct sql: ${d_b};; } measure: m_c { label: "meas c" type: count_distinct sql: ${d_c} ;; }