Often, we come across datasets where each row represents a date range a Start date and an End date. But what if we want to break these ranges into individual months, like Jan-2025, Feb-2025, etc.? Whether you’re preparing reports, planning usage analysis, or aligning with monthly KPIs this transformation becomes super useful.
In this blog post, I’ll walk you through a Power Query M script that takes these Start-End dates and transforms them into distinct monthly periods for each record.
Get Access to Your File
Enter your name and email to receive access to the file.
Understand the sample data & output
Name | Start | End |
---|---|---|
Ali | 1-Jan-25 | 10-Mar-25 |
Sara | 15-Feb-25 | 20-Apr-25 |
Our goal is to create a new list that shows every month-year combination that falls within those date ranges for each name and the output should look like this.
Name | Period |
---|---|
Ali | Jan-2025 |
Ali | Feb-2025 |
Ali | Mar-2025 |
Sara | Feb-2025 |
Sara | Mar-2025 |
Sara | Apr-2025 |
Step-by-Step how query works
- Convert data into table -> Select Range -> Insert -> Table
- Give the Table Name in our example we used it as “Table1”
- Load the Table in Power Query
- Only for Mac currently you need select blank query and then write in source “Excel.CurrentWorkbook()”
- Windows right click and load data Table/Range
- Change Types : Convert Start and End columns to Date format
- Round to Full Months
- Change Start to the first day of the month.
- Change End to the last day of the month.
- Generate a Date List
- Convert dates to numbers to create a list using {[Start]..[End]} by adding custom column.
- Expand this list into rows.
- Extract Period Info
- Get the Year Select Transform > Date > Year > Year
- Get The Month Select Transform > Date > Month > Name Of the Month.
- Extract only 3 character only from Name Of the Month.
- Merge Name Of the Month + Year to convert it into MMM-YYYY format like Jan-2025.
- Remove the column that are not required.
- Remove the duplicate by selecting the name and period column
- Your Data is ready
This format is perfect for monthly reports, aggregations, dashboards, or preparing a calendar-based dataset for Power BI.