Merge Queries Column and Date if Date is less than or equal to

jilbobagins

Member
Joined
Apr 11, 2019
Messages
80
Reaction score
0
Points
6
Excel Version(s)
2016
Howdi,

I'm hoping I can explain this well enough, I've spent most of the morning searching but to no avail.

I have 2 Tables/Queries (Details below) I want to merge the tables by the [Item] and [Dates] however I only want to merge those rows where the [Promised Date] from table 2 is less than or equal to the [Required Date] of table 2. Additionally I only want to display the 'Max' promised date that is less than or equal to (Highlighted the [running sum] total I wish to ultimately expand and show in the first table.

Hope this makes sense...

First table

I
IndexItemRequired DateQty Req
1JL12324/03/205
2JL124530/03/204
3DL451624/03/207
4TH889827/03/206


Second Table

IndexItemPromised DateSum QtyRunning Sum
1JL12318/03/2044
2JL12321/03/2059
3JL12323/03/20211
4JL12327/03/20415
5JL124526/03/2022
6JL124504/04/2057
7JL124515/05/20411
8DL451622/03/2055
9DL451624/03/20914
 
Hi there,

I've knocked up something that will get you there for the merge. One caveat though, is that I haven't done the Accumulate bit in PQ, but rather as a PivotTable. The reason for this is that accumulations are super easy and efficient in PivotTables, but the accumulator functions in Power Query can be VERY slow, so aren't recommended.

Hope this helps!
 

Attachments

  • 10539.xlsx
    25.2 KB · Views: 18
Thank you Ken !! I will give this a go and see how I get on :canada:
 
Back
Top