I needed to write a filter that used an OR statement to pull the department values from one explore join (the IN part of the referral) OR the another explore join (the OUT part of the referral). Unfortunately, this functionality just doesn't exist in Looker. I had to find another way.
Here's my explore with 5 joins. The last join contains the OR statement: the final solution to this problem. The first 4 joins set up the in and out assignment of departments for both the referral and the revenue from the referral.
explore: flatfile {
join: referred_to_dept {
view_label: "referred to department"
from: v_dim_dept
type: left_outer
relationship: one_to_one
sql_on: ${flatfile.referred_to_dept_id} = ${referred_to_dept.branch};;
}
join: referrers_dept {
view_label: "referrer department"
from : v_dim_dept
type: left_outer
relationship: one_to_one
sql_on: ${flatfile.referrers_dept_id} = ${referrers_dept.branch};;
}
join: rev_in_dept {
view_label: "revenue in department"
from: v_dim_dept
type: left_outer
relationship: one_to_one
sql_on: ${flatfile.rev_in_deptid} = ${rev_in_dept.branch};;
}
join: rev_out_dept {
view_label: "revenue out department"
from : v_dim_dept
type: left_outer
relationship: one_to_one
sql_on: ${flatfile.rev_out_deptid} = ${rev_out_dept.branch};;
}
#This join is specifically for the hierarchy filters to pull department information with an OR join
# for either referral IN or referral OUT
join: v_dim_dept {
view_label: "dim department (in/out combined)"
type: inner
relationship: one_to_one
sql_on: ${flatfile.referrers_dept_id} = ${v_dim_dept.branch}
OR ${flatfile.referred_to_dept_id} = ${v_dim_dept.branch}
;;
}
Comments
Post a Comment