• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Conditional Merge between Dates|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Conditional Merge between Dates|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryConditional Merge between Dates
sp_PrintTopic sp_TopicIcon
Conditional Merge between Dates
Avatar
Beth Lewis
Virginia
Member
Members
Level 0
Forum Posts: 7
Member Since:
November 27, 2018
sp_UserOfflineSmall Offline
1
July 14, 2022 - 8:39 am
sp_Permalink sp_Print

I have a set of codes each month, and a date on each code - 202201, 202202, 202203, etc. I can turn those codes into dates, for example '01/15/2022', '02/15/2022', '03/15/2022'

Each month the code has a number of rows and columns in a lookup table, defined by an effective and end date.

For example, Code1 has two date ranges: Effective from 01/01/2021 to 01/31/2022, and then another range from 02/01/2022 to a high end date (still active).

I cannot find an example of how to join two data sets based on a join field (the code) between two dates in my lookup table, where I return multiple columns and rows from the lookup table. I am trying to understand the products associated with my codes over time, and I know they change.

Are there functions or techniques to do this?

Any suggestions, pointers or concepts to research would be greatly appreciated! Thanks - Beth

 
Month Code   Code Effective End Products
202201 Code1   Code1 1/1/2021 1/31/2022 a
202203 Code1   Code1 1/1/2021 1/31/2022 b
202203 Code1   Code1 1/1/2021 1/31/2022 c
      Code1 2/1/2022 12/31/9999 a
      Code1 2/1/2022 12/31/9999 b
      Code1 2/1/2022 12/31/9999 d
      Code1 2/1/2022 12/31/9999 e
sp_AnswersTopicSeeAnswer See Answer
Avatar
Alan Sidman
Steamboat Springs, CO
Member
Members


Trusted Members
Level 0
Forum Posts: 132
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
2
July 14, 2022 - 10:31 am
sp_Permalink sp_Print

Trying to understand what you want the end result for the data in the two tables to look like.  Can you please supply a mocked up version for the data you have supplied.  If you upload sample data then we will not have to retype your source data and mocked up result to achieve a workable solution.

Avatar
Beth Lewis
Virginia
Member
Members
Level 0
Forum Posts: 7
Member Since:
November 27, 2018
sp_UserOfflineSmall Offline
3
July 14, 2022 - 11:50 pm
sp_Permalink sp_Print

Sure. See attached. I also included typical SQL I would use if the data were in SQL Server... I meant to name my tables for you, but now can't seem to delete the first upload... 

Appreciate any help Alan! Beth

Avatar
Adam Bender
Minneapolis, MN

Active Member
Members

Power Query
Level 0
Forum Posts: 5
Member Since:
June 14, 2022
sp_UserOfflineSmall Offline
4
July 15, 2022 - 1:37 am
sp_Permalink sp_Print

I've had this problem before, and I eventually concluded that there is no such thing as "between" in Power Query.

There are multiple options, including adding a custom column that contains a list of all the dates possible, then joining on that date column, then filtering, but it's extremely expensive.

This solution (link below) seems to have a better way, and it's similar to a "between" join, but also requires a custom column.  You might try this out first.

https://community.powerbi.com/.....m-p/505197

sp_AnswersTopicAnswer
Answers Post
Avatar
Beth Lewis
Virginia
Member
Members
Level 0
Forum Posts: 7
Member Since:
November 27, 2018
sp_UserOfflineSmall Offline
5
July 15, 2022 - 5:20 am
sp_Permalink sp_Print

THANKS ADAM!

This worked on my test data, and lets me pull in any of the columns I need from the reference table. I have some fairly large data sets to work with, so I will have to see if this is efficient enough to be an actual solution, but for now - looks like it works like a charm! Smile

CHEERS!!

Avatar
Beth Lewis
Virginia
Member
Members
Level 0
Forum Posts: 7
Member Since:
November 27, 2018
sp_UserOfflineSmall Offline
6
July 15, 2022 - 5:30 am
sp_Permalink sp_Print

Including the solution file, with power queries. Beth

The following users say thank you to Beth Lewis for this useful post:

Anders Sehlstedt
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham, Ramon Lagos
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.