Locked lesson.
About this lesson
It's now time to build a dynamic calendar on the fly for our sample model. After identifying your calendar's start and end dates, it's one line of code, 5 clicks, 4 characters and the Enter key, and you're set.
Exercise files
Download this lesson’s related exercise files.
Creating Dynamic Calendars - Application.xlsx731.3 KB Creating Dynamic Calendars - Application - Completed.xlsx
829.7 KB
Quick reference
Creating Dynamic Calendars - Application
A demonstration of creating a dynamic self-updating calendar for your model.
When to use
When you need to build a calendar table on the fly that covers your entire date range.
Instructions
Create the StartDate query:
- Connect to (or reference) a Power Query with the earliest possible data
- Remove all columns except the Date column
- Filter to earliest dates and remove duplicates
- Convert to StartOfYear if required
- Right click the single cell and Drill Down
- Name the Query StartDate
- Load as a Connection Only query (do not load to the Data Model)
Create the EndDate query:
- Repeat the steps above but focus on creating the EndDate
Create the Calendar query:
- Create a new Blank Query
- In the formula bar enter the following formula:
={Number.From(StartDate)..Number.From(EndDate)}
- Go to List Tools --> Transform --> To Table
- Click OK with the default options
- Change the data type of Column1 to Date
- Rename Column1 to Date
- Add other date columns as desired
- Load the query and link it in to your model
Hints & tips
- The StartDate and EndDate do not need to come from the same base query
- A good candidate for the EndDate is a Budget table, as budgets are typically prepared before the actual transactions occur
Lesson notes are only available for subscribers.