(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

PL-300: how to create smart date columns for time analysis

João Barros 10 de September de 2026 4 min read

I will teach how to create and use date columns (calendar table) in Power BI — a frequent competency in the "Model the data" domain of the PL-300. Knowing how to build a correct calendar is essential for time analyses (period-to-period, YTD, comparisons) and prevents errors in reports and DAX calculations.

What you need to know

A calendar table (or date dimension) contains one row per day in a range and columns with attributes such as Year, Quarter, Month, Day of week, plus flags like "Is end of month" or "Is weekend". In Power BI, it enables the use of time intelligence functions in DAX (for example, TOTALYTD, SAMEPERIODLASTYEAR) and ensures that relationships between dates and fact tables work correctly.

Simple example: a Sales fact table with the column Sale[OrderDate]. To calculate Sales YTD correctly you need a Date table with a column Date[Date] that includes all dates in the relevant range and, ideally, a field that indicates the first day of the month or year.

How it works: creating a calendar table with DAX

There are several ways to create a calendar: in Power Query (M), as a physical table in a database, or with DAX (calculated table). Here I show a DAX method that is practical for models in Power BI Desktop.

Calendar =
VAR MinDate = MINX(ALL('Sales'), 'Sales'[OrderDate])
VAR MaxDate = MAXX(ALL('Sales'), 'Sales'[OrderDate])
RETURN
ADDCOLUMNS(
    CALENDAR(MinDate, MaxDate),
    "Year", YEAR([Date]),
    "Quarter", "Q" & FORMAT([Date], "Q"),
    "MonthNum", MONTH([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "YearMonth", FORMAT([Date], "YYYY-MM"),
    "DayOfWeekNum", WEEKDAY([Date], 2),
    "DayOfWeek", FORMAT([Date], "dddd"),
    "IsWeekend", IF(WEEKDAY([Date],2) >= 6, TRUE(), FALSE())
)

Quick explanation of the parts:

  • CALENDAR(MinDate, MaxDate) generates all dates between the minimum and maximum sales dates.
  • ADDCOLUMNS adds useful columns: Year, Quarter, MonthName, etc.
  • WEEKDAY([Date], 2) with 2 makes Monday=1 ... Sunday=7 — useful for sorting.

In practice: connect the calendar table and use measures

Practical steps to follow in Power BI Desktop:

  1. Create the calendar table (e.g., calculated table with the DAX above or in Power Query).
  2. Ensure the date column in the Calendar table is of type Date and has no time component.
  3. Create a 1:* relationship between Calendar[Date] and Sales[OrderDate], with the appropriate filter direction (typically single direction from Calendar to Sales).
  4. Mark the table as "Mark as Date table" (Modeling > Mark as date table) and indicate Calendar[Date]. This allows DAX time intelligence functions to work correctly.
  5. Use DAX time measures. Example: Sales YTD.
SalesAmount = SUM(Sales[Amount])

SalesAmount_YTD =
TOTALYTD(
    [SalesAmount],
    'Calendar'[Date]
)

SalesAmount_PY =
CALCULATE(
    [SalesAmount],
    SAMEPERIODLASTYEAR('Calendar'[Date])
)

Practical notes: marking the date table is crucial; without this, TOTALYTD and similar functions may return incorrect results. Visually sort the month by MonthNum if you use MonthName to avoid January, February,... being out of order.

Common mistakes

  • Not marking the table as "Date table" — causes time intelligence functions to fail.
  • Dates with time in Sales[OrderDate] do not match Calendar[Date] (DateTime vs Date type) — resolve by truncating or converting to Date.
  • Incorrect relationships (many-to-many or reversed filter direction) — the relationship should be 1 (Calendar) → * (Fact) for time functions to work well.

How to practice

Practice this topic by creating several scenarios: ranges with gaps, fact tables with multiple date columns (OrderDate, ShipDate), and using slicers by month/year. For PL-300 preparation, use the official Microsoft Practice Assessment and the official study guide (both free) — these are the appropriate ways to assess and verify your knowledge without resorting to prohibited materials.

In summary

  • Create a complete calendar table and mark it as "Date table" to enable time intelligence functions in DAX.
  • Ensure the date column contains only dates (no time) and that the relationship is 1:*> between Calendar and the fact table.
  • Use additional columns (Year, MonthNum, DayOfWeek) to sort and group correctly in visuals.
  • Practice with the official Practice Assessment and the Microsoft study guide — both free — and try computing YTD, MTD and year-over-year comparisons.