Power query: Merge with 2 conditions

Hello all of you!
I hope everyone’s ok here.

Last week i asked for a solution to merge a table on power query base on 1 condition only i guess. Now my table is different, which means, 2 conditions. Let me explain:

I need to lookup a table (Tab Employee Rates) for a particular employee id and the date of the fact table should be greater or equal than the lookup table. The purpose of this is to get the real hour value for each employee.

I’ve post this question :

and @Melissa helped on this. It use to work but only for one condition which was date. Now i have to check both conditions date, and worker id .
Here’s my (not working code)

BufferedTable = Table.Buffer (Table.Sort( #“Tab Employee Rates”,{{“DateR”, Order.Ascending}} )),
GetValue = Table.AddColumn(#“Renamed Columns”, “Unit Value”, each
try Table.LastN(
Table.SelectRows( BufferedTable, (BT) => BT[DateR] <= [Date] ),
1){0}[valor] otherwise null, type number),

I’ve attach a sample and it would be awesome if you guys could help me.
Thanks a lot
Pedro
Sample.xlsx (222.8 KB)

Hi @pedroccamara,

See if this meets your requirement.

Sample (2).xlsx (162.9 KB)

1 Like

Yeah it’s working! Amazing @Melissa!
You’re such a boss!
Thank you so so so much

If you have any questions let me know, I’d be glad to provide more details later but I had to run…

1 Like