This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi All,
I have two tables/queries (snippet below) and what I am trying to do is match the driver from the table/query 1 to table/query 2 based on the following criteria - Car (Table2) matches Car (Table1) and Report Date (Table2) falls inbetween Commence date (Table1) and End Date (Table1)
Table/Query1
| Car | Driver | Commence Date | End Date |
| Nissan | Will | 01/01/2018 15:06 | 01/04/2018 10:00 |
| Nissan | Charlie | 01/04/2018 10:00 | 02/05/2018 09:00 |
| Fiat | Peter | 25/03/2018 00:00 | 31/04/2018 11:54 |
| Mazda | Jan | 03/02/2018 13:43 | 04/05/2018 09:36 |
| Mazda | Jan | 04/05/2018 09:36 | 21/05/2018 11:00 |
| Mazda | Ben | 21/05/2018 11:00 | 09/06/2018 13:43 |
Table/Query2
| Car | Report Date |
| Nissan | 31/04/2018 11:33 |
| Fiat | 25/03/2018 00:00 |
| Mazda | 07/05/2018 13:24 |
Therefore, for the above you would finish with the below
| Car | Report Date | Driver |
| Nissan | 31/04/2018 11:33 | Charlie |
| Fiat | 25/03/2018 00:00 | Peter |
| Mazda | 07/05/2018 13:24 | Ben |
Does anyone have any ideas?
Many Thanks,
Jack
Solved! Go to Solution.
Are you looking to do it with a calculated table?
Table =
ADDCOLUMNS (
Table2,
"Driver",
VAR tCar = Table2[Car]
VAR Dte = Table2[Report Date]
RETURN
CALCULATE (
VALUES ( Table1[Driver] ),
Table1[Car] = tCar,
Table1[Commence Date] <= dte,
Table1[End Date] >= Dte
)
)
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Are you looking to do it with a calculated table?
Table =
ADDCOLUMNS (
Table2,
"Driver",
VAR tCar = Table2[Car]
VAR Dte = Table2[Report Date]
RETURN
CALCULATE (
VALUES ( Table1[Driver] ),
Table1[Car] = tCar,
Table1[Commence Date] <= dte,
Table1[End Date] >= Dte
)
)
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 40 | |
| 37 | |
| 31 | |
| 23 | |
| 15 |
| User | Count |
|---|---|
| 76 | |
| 59 | |
| 31 | |
| 31 | |
| 25 |