<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=612681139262614&amp;ev=PageView&amp;noscript=1">
Skip to content

Need help? Talk to an expert: phone(904) 638-5743

Dynamic Date Table Using the Power Query Editor

Dynamic Date Table Using the Power Query Editor

In a recent training session, Angelica Choo Quan demonstrated how to create a dynamic date table using Power BI’s Power Query Editor. This tutorial is especially useful for those looking to implement time intelligence functions and enhance their reporting capabilities.

 

Why Use a Separate Date Table?

  • Time Intelligence Functions: Power BI requires a dedicated date table to perform calculations like Year-to-Date, Quarter-to-Date, and Month-to-Date.
  • Granular Analysis: Enables drilling down into year, quarter, month, week, and day levels.
  • Customization: Add columns for fiscal periods, holidays, and working days.
  • Multiple Fact Tables: A shared date table allows filtering across multiple fact tables in your model.

Step-by-Step Guide to Building the Date Table

  1. Create a Blank Query:
    • Go to Home > New Source > Blank Query.
    • Use the formula: DateTime.LocalNow() to get the current date and time.
    • Convert the result to a table and change the column type to Date.
    • Rename the column to Current Date.
  2. Calculate 3 Years Prior:
    • Add a custom column using Date.AddYears([Current Date], -3).
    • Rename this column to 3 Years Prior and set its type to Date.
  3. Determine Start of Year:
    • Add another custom column: Date.StartOfYear([3 Years Prior]).
    • Name it Start Date and convert it to Date type.
  4. Set End Date (6 Months Ahead):
    • Create a column using Date.AddMonths([Current Date], 6).
    • Name it End Date and set the type to Date.
  5. Generate Full Date List:
    • Add a custom column to create a list of dates between Start and End Dates:
    • {Number.From([Start Date])..Number.From([End Date])}
    • Expand this list to new rows and convert to Date type.
    • Keep only this column and rename it to Date.
  6. Enhance the Date Table:
    • Use the Add Column tab to extract:
      • Year
      • Quarter
      • Month Number
      • Month Name
    • Rename the query to Date Table.

Conclusion

This dynamic date table setup allows users to perform advanced time-based analysis and forecasting in Power BI. By leveraging Power Query Editor, users gain flexibility and control over their data model, enabling more insightful reporting and decision-making.

Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power BI and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks. 

Sign-up now and get instant access

Leave a comment

Free Trial

On-demand learning

Most Recent

private training

Hackathons, enterprise training, virtual monitoring