An M Query to create a repeatable date dimension table.
Rather than creating a table from scratch, this offers a quick way to create a date table for you to create relationships with.
- Open up Power BI and on the Home Tab, click Transform data.
- On the Home Tab click on the words New Source, then Blank Query.
- A New Query entitled Query1 will be created. On the Home Tab, click Advanced Editor.
- In the new Window that opens up, select all and replace with the contents of the text file.
- Select Done.
Congratulations, the hard work is done!!
- Click on Query1, and select your earliest date you wish to have in the table in the StartDate box by either inputting directly as MM/DD/YYYY or by clicking the calendar button.
- Select your latest date you wish to have in the table in the EndDate box by either inputting directly as MM/DD/YYYY or by clicking the calendar button.
- Once you are happy with the earliest (StartDate) and latest (EndDate) dates in your table, click the Invoke button.
- This will create a new Table currently entitled Invoked Function. Remember to right-click and rename to whatever naming convention is appropriate to your naming convention. Congratulations!!
This will create a table ready to go with the appropriate labels and data types selected!
Direct inspiration from Devin Knight's query at: https://devinknightsql.com/2015/06/16/creating-a-date-dimension-with-power-query/