I have two queries where i can merge them with the "ID". The phase query has the phase ID, and the phase start and end date. The other query has hour values and a date value, and i want to add a column to this query with the Phase name, depending on which phase date range the date value is in. See below tables (or attached image with colours for better explanation). I'm using Power BI so i'd like to be able to do this in either Power BI or Power Query. I hope it makes sense and that someone knows how to solve this
Phase query | |||
ID | Phase Name | Phase Start date | Phase end date |
1 | A | 01-01-2022 | 31-01-2022 |
1 | B | 01-02-2022 | 28-02-2022 |
2 | B | 01-02-2022 | 28-02-2022 |
3 | A | 01-03-2022 | 20-03-2022 |
3 | B | 01-04-2022 | 15-04-2022 |
Hour query | All i need to get my result is to add the phase here with a merge or similar | ||
ID | Hours | Date | Phase |
1 | 2 | 05-01-2022 | ? |
1 | 3 | 07-02-2022 | ? |
2 | 2 | 10-02-2022 | ? |
2 | 10 | 01-01-1901 | ? |
3 | 5 | 05-03-2022 | ? |
3 | 8 | 02-04-2022 | ? |
3 | 3 | 08-04-2022 | ? |
Result (visualisation) | ||
ID | Hours (combined) | Phase |
1 | 2 | A |
1 | 3 | B |
2 | 2 | B |
3 | 5 | A |
3 | 11 | B |