Module 7 · Power BI Fundamentals
Data modelling
Finish the star schema with a proper date table, sort months correctly, and tidy the model so reports are easy to build.
About 35 minutes
The problem
You want revenue by month, and year-on-year comparisons. Grouping by order_date alone gets messy: months sort alphabetically (April, August, December…), there's nothing to group quarters by, and DAX's time functions (next lessons) need a complete calendar. The answer is a date table.
The concept
Why a date table?
- One row per day, with no gaps, covering the whole period.
- Columns to group by: year, quarter, month name, month number.
- Required for reliable time intelligence in DAX (year-to-date, same period last year).
Build it with DAX (Modeling → New table):
DAX
Date =
ADDCOLUMNS (
CALENDAR ( DATE ( 2025, 1, 1 ), DATE ( 2026, 12, 31 ) ),
"Year", YEAR ( [Date] ),
"Quarter", "Q" & ROUNDUP ( MONTH ( [Date] ) / 3, 0 ),
"Month Number", MONTH ( [Date] ),
"Month", FORMAT ( [Date], "mmm" ),
"Year Month", FORMAT ( [Date], "yyyy-mm" )
)Then:
- Mark as date table: select the table → Table tools → Mark as date table → choose the
Datecolumn. - Relate
Date[Date](1) →orders[order_date](*). - Sort by column: select
Month→ Column tools → Sort by column → Month Number. Now months sort January to December.
Tidy model habits
- Hide ID and technical columns report builders shouldn't use.
- Give tables and columns clear names (
Revenue, notSum of revenue2). - Set formats once in the model (currency, thousands separators), not on every visual.
- Keep calculations as measures (next lessons) rather than many calculated columns.
- Turn off Auto date/time (File → Options and settings → Options → Current file → Data Load) once you have your own date table. It creates hidden date tables for every date column and bloats the file.
Example
The finished model:
customers (1) ──* orders *── (1) products
*
│
(1) DateNow Date[Year] and Date[Month] on a matrix, orders[revenue] in values, gives a correctly sorted month-by-year grid.
Walkthrough
- Modeling → New table, paste the DAX above, press Enter.
- Mark it as a date table.
- In Model view, drag
Date[Date]ontoorders[order_date]. Check it's one-to-many, single direction. - Sort
MonthbyMonth Number. - Build a Matrix: Rows
Date[Year], thenDate[Quarter]; Valuesorders[revenue]. Expand a year with the + icons. - Hide
orders[order_date]in report view, so everyone usesDateinstead.
Practice
Practice
Using the date table, what was revenue in Q2 2026 (April–June), to the nearest naira?
Practice
How many rows does the Date table built with the DAX above contain?
Check your understanding
Answer every question to check.