Forum Discussion
Power Query - Join/Merge based on Date between 2 dates
- 6 years ago
Hi there,
there is actually a pattern for this task that will probably increase speed: https://www.skillwave.training/vlookup-true-in-power-query/
Also see attached file.
It delivers correct results if the intervals are without gaps like in the data pedanticpad gave in his initial thread.
The following in M will do what you want.
#"Added Custom" =
Table.AddColumn(#"Changed Type", "Some Number", each let
varDate = [Sales Date]
in
Table.SelectRows(Table, each [Date1] <= varDate and [Date2] >= varDate)[Some Number]{0}
)
You can see it in this PBIX file.
Note my data has some errors in the results because my Sales table has dates not in the Table date ranges. If you have the same issue you could wrap in a try/otherwise construct.
If you want more help, please provide data per links below, not screenshots. Thanks!
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum
Worked perfectly, thanks so much!