Forum Discussion
Breaking time intervals into smaller intervals
Hi Experts,
I'm hoping to get your help with creating a payments schedule table based on a contracts table. The existing table is similar to this:
| Contract | Valid from | Valid to | Pay frequency | Notes |
| A | 10/1/2019 | 8/31/2020 | quartely | 11 mths |
| B | 9/1/2019 | 8/31/2020 | bi-annual | 12 mths |
| C | 10/1/2019 | 10/31/2020 | annual | 13 mths |
| D | 9/1/2019 | 11/30/2020 | one-time | 14 mths |
I added the "Notes" column just to highlight that for some contracts the last payment is for a shorter time interval than the rest.
The desired outcome would be another table looking like this:
| Pay ID | Pay from | Pay to |
| A1 | 10/1/2019 | 12/31/2019 |
| A2 | 1/1/2020 | 3/31/2020 |
| A3 | 4/1/2020 | 6/30/2020 |
| A4 | 7/1/2020 | 9/30/2020 |
| B1 | 9/1/2019 | 2/29/2020 |
| B2 | 3/1/2020 | 8/31/2020 |
| C1 | 10/1/2019 | 9/30/2020 |
| C2 | 10/1/2020 | 10/31/2020 |
| D1 | 9/1/2019 | 11/30/2020 |
Your help will be much appreciated!
2 Replies
- Greg_Deckler
Community Champion
Anonymous - Hmm, not sure there is a way to do that at scale. In DAX you could brute force it by using GENERATE between the to and from for each row, filter out what you don't need and then a UNION of everything. That would be OK if it was 4 rows but I doubt you really only have 4 rows. Maybe if you unpivot your from and to columns first. Will have to think about it.
- AnonymousNot applicable
Greg_Deckler Thanks for looking into this. You are right about the brute force, the source table has a lot more than 4 rows and is often updated.