Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TurloughHendry
Frequent Visitor

Compare dates in two tables to return corresponding value to that date

I am working with HR information. I have two tables one table is time sheets which are exported weekly, and i am trying to intergrate a change in circumstances table. The reason I am trying to do this is that the weekly timesheet export will only showthe current job role, department and contracted hours of the employee.

 

TurloughHendry_0-1677800420700.png

 

I needs to be able to look back retrospectively to the Change In Circumstances, and be able to with a new column, say if the timesheet is on eg. 02/01/2022 Joe's job role is Junior Analyst not Senior Analyst

 

Ideally a table like this:

TurloughHendry_1-1677800514618.png

 

3 REPLIES 3
TurloughHendry
Frequent Visitor

Currently i have tried adding a custon column in power query with this:

 

let mydate=[Timesheet date] in
Table.SelectRows([Change In Circumstances], each [Date Chnaged] <= mydate)

 

It returns the correct first change, but if the job changes more than one, for the second and thrid job change, it duplicated leaving me with this:

 

TurloughHendry_0-1677800958636.png

 

you're almost there. 

suppose your data in change log table is already sorted by date, then you just need to get the last record.

let mydate=[Timesheet date] in
Table.LastN(Table.SelectRows([Change In Circumstances], each [Date Chnaged] <= mydate),1)

Thanks for the response, its appreciated!!

 

For some one that goes through more than two jobs changes, it seems to only pull through the second, and not the thrid:

 

TurloughHendry_0-1677808684677.png

 

When ideally it needs to be:

TurloughHendry_1-1677808706144.png

 

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.