13.3Working with dates and times

Your data almost always has dates. These functions cut them up, build them and shift them. They return a single value, and are often used in the calculated columns of the calendar. The examples start from the date of sale V001, 1/15/2024.

13.3.1YEAR, QUARTER, MONTH and DAY

In Excel
DAXYEARQUARTERMONTHDAY
ExcelYEARROUNDUP(MONTH(d)/3,0)MONTHDAY
Match

You need them when you want part of a date, the year to compare 2024 and 2025, or the month. That is how the “Year” or Month columns of a Calendar table are built.

They return the year, the quarter, the month and the day of a date, like YEAR, MONTH and DAY in Excel.

The syntax of YEAR, QUARTER, MONTH and DAY
The yearYEAR( <date> )
The quarterQUARTER( <date> )
The monthMONTH( <date> )
The dayDAY( <date> )

Each one expects a single argument, a date, most often a column of dates written with its table, like Sales[Date].

On the V001 row, dated 1/15/2024:

  • YEAR( Sales[Date] ) returns 2024.
  • QUARTER( Sales[Date] ) returns 1.
  • MONTH( Sales[Date] ) returns 1.
  • DAY( Sales[Date] ) returns 15.

This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.

Practice

Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.

  1. Direct useCalculated columnDifficulty

    A library records the date each reader joined, in the “Memberships” table. Add the calculated column “Year” to the “Memberships” table, the year the reader joined.

    Memberships
    ReaderJoined
    Lina2/14/2025
    Marc9/3/2026

    Which formula should you write for “Year”?

  2. Combined useCalculated columnDifficulty

    The library tells its long-standing readers, who joined before 2026, from the new ones. Add the calculated column “Status” to the “Memberships” table, which shows “Existing” or “New”.

    Memberships
    ReaderJoined
    Lina2/14/2025
    Marc9/3/2026
  3. Direct useCalculated columnDifficulty

    A hotel wants to count its arrivals per quarter. Add the calculated column “Quarter” to the “Stays” table, the quarter of the arrival date.

    Stays
    GuestArrival
    Alma1/2/2026
    Bilal5/12/2026
    Chloé11/28/2026
  4. Combined useCalculated columnDifficulty

    The hotel does its accounts by half-year. Add the calculated column “Half Year” to the “Stays” table, 1 or 2.

    Stays
    GuestArrival
    Alma1/2/2026
    Bilal5/12/2026
    Chloé11/28/2026
  5. Direct useCalculated columnDifficulty

    A school prepares the birthdays of each month. Add the calculated column “Birth Month” to the “Students” table, the number of the month.

    Students
    StudentBirth Date
    Alma3/21/2016
    Bilal10/8/2015
    Chloé3/30/2016
  6. Combined useMeasureDifficulty

    The school wants to prepare the March birthday party. Write the “Born in March” measure, the number of students of the “Students” table born in March, whatever the year. You will read it in a card.

    Students
    StudentBirth Date
    Alma3/21/2016
    Bilal10/8/2015
    Chloé3/30/2016
  7. Direct useCalculated columnDifficulty

    A sports club collects the fee every month, on the same day as the start of the subscription. Add the calculated column “Debit Day” to the “Subscriptions” table.

    Subscriptions
    MemberStart
    Inès1/14/2026
    Hugo2/3/2026
  8. Combined useCalculated columnDifficulty

    The club collects in two waves, on the 15th for the subscriptions started in the first half of the month, on the 30th for the others. Add the calculated column “Wave” to the “Subscriptions” table, which shows “On the 15th” or “On the 30th”.

    Subscriptions
    MemberStart
    Inès1/14/2026
    Hugo2/3/2026
    Jade1/22/2026

The rest of this lesson is part of izyDAX Pro

You have just read the first section. The next 5, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.