Forum Discussion
Jug
3 years agoFrequent Visitor
Relate two tables by a date range.- DirectQuery
I need to relate two tables by a code and a date range. For example: where TABLE1.SERVICE_CODE = TABLE2.SERVICE_CODE and TABLE1.SERVICE_DATE between TABLE2.START_DATE and TABEL2.END_D...
- Anonymous3 years ago
Hi Jug ,
You can create a measure for filtering.
Measure = IF(MAX('TABLE 1'[SERVICE_CODE])=MAX('TABLE 2'[SERVICE_CODE])&&MAX('TABLE 1'[SERVICE_DATE])>=MAX('TABLE 2'[START_DATE])&&MAX('TABLE 1'[SERVICE_DATE])<=MAX('TABLE 2'[END_DATE]),1)No relationship between tables.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
3 years agoSuper User
Jug , a new measure
maxx(filter(Table2, max(Table1[Service_code]) = Table2[Service_code] && max( Table1[service_date] ) >= (Table2[Start_date]) && max(Table1[service_date]) <= max(Table2[Start_date] ) ), Table2[Service Description])