Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Date.IsInPreviousQuarter Function Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Date.IsInPreviousQuarter function in Power Query checks whether a given date falls within the calendar quarter immediately before the current one — for example, if today is in Q3 2024, this function returns true for any date in Q2 2024 (April–June 2024). It requires a valid date or datetime value and works relative to the system clock at query execution time. No additional setup is needed beyond having a column or expression that evaluates to a date type.

What You'll Need

  • A Power Query environment (available in Excel, Power BI Desktop, or Power Automate)
  • A column or custom column containing date/datetime values (e.g., OrderDate, TransactionDate)
  • Understanding that the function uses the current system date and time at execution — not a static reference

Step-by-Step

  1. Open your Power Query Editor (in Excel: Data > Get Data > Edit Queries; in Power BI: Home > Transform Data)
  2. Select the table containing your date column (e.g., a table named SalesData with a column OrderDate)
  3. Click Custom Column from the Add Column tab (or right-click the table and choose New Column in Power BI)
  4. In the formula bar, enter the expression: Date.IsInPreviousQuarter([OrderDate]) — replace [OrderDate] with your actual date column name
  5. Press Enter to apply the column. Power Query will populate a new column of Boolean values (true or false) indicating whether each row’s date falls in the prior quarter
  6. To filter only previous-quarter rows, click the dropdown arrow on the new column header, uncheck false, and click OK
  7. Click Close & Apply (Power BI) or Close & Load (Excel) to push the filtered data back to your worksheet or report

Common Mistakes

  • Using the wrong column reference — for example, typing Date.IsInPreviousQuarter(OrderDate) without brackets instead of [OrderDate]. Power Query requires square brackets for column references
  • Assuming it works with text or numeric date representations — the function expects a true date or datetime type. If your dates are stored as text (e.g., "2024-04-15"), convert them first using Date.From or Table.TransformColumns
  • Forgetting that it’s relative to the *current* system time — if you run the query on April 1, 2024, Q1 2024 (Jan–Mar) is the previous quarter. On July 1, Q2 (Apr–Jun) becomes the previous quarter. It does not support fixed or custom reference dates
  • Confusing it with Date.IsInCurrentQuarter or Date.IsInNextQuarter — double-check the function name spelling to avoid logic errors

Tips

  • Combine with Date.QuarterOfYear to debug: create a helper column showing the quarter number of each date (e.g., Date.QuarterOfYear([OrderDate])) to verify expected behavior
  • For dynamic reporting, consider storing today’s date in a separate query (e.g., Today = DateTime.LocalNow()) and use Date.IsInPreviousQuarter only when you truly need *relative* to *now*
  • If your data spans multiple years, add a year filter first (e.g., if [OrderDate] > #datetime(2020,1,1,0,0,0) then Date.IsInPreviousQuarter([OrderDate]) else null) to avoid unexpected results with very old dates
  • Use try ... otherwise to handle nulls safely: try Date.IsInPreviousQuarter([OrderDate]) otherwise false

Troubleshooting

If your Date.IsInPreviousQuarter column returns all false or errors:

  1. Check data types — right-click the date column header and ensure Data Type is set to Date or DateTime. If it’s Any or Text, click the type icon and choose Date
  2. Test with a known date — add a custom column with = #date(2024, 5, 15) and apply Date.IsInPreviousQuarter. On any date in Q3 2024 or later, this should return true — if not, your system clock may be incorrect
  3. Verify your system clock — open date and time settings on your PC or device. If the year, month, or quarter displayed is wrong, the function will behave incorrectly
  4. Look for hidden time components — if your date includes a time (e.g., 2024-04-01 14:30), Date.IsInPreviousQuarter still works correctly. However, ensure your system’s current quarter aligns with your expectations (e.g., Q2 ends June 30)
  5. Check for nulls — if your source data contains blank or null dates, the function returns null. Use Table.ReplaceNulls or a conditional column to replace null with false before filtering

Frequently Asked Questions

Does Date.IsInPreviousQuarter work with fiscal quarters?

No — it strictly follows the calendar year (Q1: Jan–Mar, Q2: Apr–Jun, Q3: Jul–Sep, Q4: Oct–Dec). For fiscal calendars, use Date.IsInPreviousPeriod with a custom calendar table or calculate quarters manually using Date.QuarterOfYear and Date.Year.

Can I use this function in a calculated column in Power BI?

No — Date.IsInPreviousQuarter is a Power Query (M) function and only runs during data transformation. In DAX (used for calculated columns and measures), use DATEADD and EOMONTH logic instead.

Why does the result change when I refresh the query later?

Because the function compares your dates to the *current* quarter at refresh time. A record dated April 10 will be true in July, but false in October — when April belongs to the *previous* quarter (Q2), not the *immediately* previous one (Q3).

Does it handle leap years or time zones?

Yes — the function uses the system’s locale and time zone settings to determine the current date. Leap years do not affect quarter boundaries (each quarter spans fixed months), but an incorrect time zone could shift the effective “current date” if near midnight.

Can I compare against a specific past quarter (e.g., Q2 2023), not just the prior one?

Not directly — Date.IsInPreviousQuarter only targets the *immediately preceding* quarter. For custom quarters, use a conditional expression like: if [Year] = 2023 and [Quarter] = 2 then true else false, where you derive Year and Quarter columns first.

What happens if I apply this to empty or missing data?

The function returns null when the input is null. If your column has no rows, it simply produces no values — no error occurs.