16.3The whole previous period

With DATEADD, you shift the days of the context. Sometimes you will rather want the whole month or year that comes before. That is the job of PREVIOUSMONTH and PREVIOUSYEAR.

16.3.1PREVIOUSMONTH

In Excel
ExcelSUMIFS between the two ends of the period (EOMONTH…)
Match

You need it when you want, next to each month, the number of the whole month before.

PREVIOUSMONTH returns all the days of the previous month, starting from the first date of the context.

PREVIOUSMONTH( <dates> )

It expects a single argument, the date column of the date table, here Calendar[Date]. Let us put this measure in a table by month:

Revenue Month Before = CALCULATE( [Revenue], PREVIOUSMONTH( Calendar[Date] ) )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table
In plain words

“I want the revenue, going back one whole month.”

On the March 2025 row, PREVIOUSMONTH starts from the first date of the context, 3/1/2025, and returns all the days of February 2025. CALCULATE replaces the filter on the dates with them, and the measure returns the number of February, 150,000. On a row that shows a single day, January 10, 2025, it returns all of December 2024, not December 10.

Year

2024

2025

Table visual, The “Revenue Month Before” measure by month, in 2025
Month NameRevenue Month Before
February200,000
March150,000
April150,000
June150,000
August150,000
October100,000
Total

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

The months whose previous month has no sales, like January or May, disappear. The “Total” row starts from 1/1/2025, and December 2024 has no sales.

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 useMeasureDifficulty

    A swimming pool already has a “Swimmers” measure, the sum of the “Swimmers” column of the “Pool” table. The “Days” date table, with its “Date” column, is marked and linked to “Pool.” In a visual by month, write the “Swimmers Month Before” measure, which takes the whole previous month.

    Pool
    DateSwimmers
    5/14/2026250
    5/28/2026310
    6/11/2026400

    Which formula should you write for “Swimmers Month Before”?

  2. Combined useMeasureDifficulty

    A weather station records the rain in the “Readings” table, in millimeters. The “Rain” measure adds up the “Rain” column. The “Days” date table, with its “Date” column, is marked and linked to “Readings.” In a visual by month, write the “Change from Month Before” measure, by how much the rain of the month changed compared with the previous month.

    Readings
    DateRain
    3/2/202612
    3/20/20268
    4/15/20265

The rest of this lesson is part of izyDAX Pro

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