Forum Discussion

qmestu's avatar
qmestu
Icon for Helper IV rankHelper IV
3 years ago
Solved

Connections between tables using date intervals

Hi,

 

I have a dataset in which i need to connect two tables using date fields. However, these are intervals, such as "START_DATE" and "END_DATE". A simplified example would be:

 

table 1:

start_dateend_datevalue
1/1/20221/6/2022A
31/6/202231/12/2022B

 

table 2:

start_dateend_datecorrespondent_value
1/3/20221/4/2022X
31/9/202230/11/2022Y

 

Choosing a slicer with the A value would result in the corresponding value being X. How can i connect these two tables?

 

Thanks.

  • Hi qmestu ,

     

    Please try:

    Apply the measure to the visual level's filter:

    Measure = IF(SELECTEDVALUE('Table 2'[start_date])>=MIN('Table 1'[start_date])&&SELECTEDVALUE('Table 2'[end_date])<=MAX('Table 1'[end_date]),1)

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • There be dragons. What should happen when multiple intervals from Table 2 match your selection from table 1?  What if the use selects multiple entries from table 1?

     

    Please consider all possible scenarios and then provide sample data that fully covers them all.

  • Hi qmestu ,

     

    Please try:

    Apply the measure to the visual level's filter:

    Measure = IF(SELECTEDVALUE('Table 2'[start_date])>=MIN('Table 1'[start_date])&&SELECTEDVALUE('Table 2'[end_date])<=MAX('Table 1'[end_date]),1)

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.