Forum Discussion
Custom Date Period Slicer To Get Last Quarter
- 4 months ago
Hi UncleLewis
The issue is that the slicer item only gives the user a selection. It does not automatically translate “Last Qtr” into the correct date range for the chart unless the slicer table is connected to the Date table in a way that actually filters the visual.
PREVIOUSQUARTER is also context-dependent. In a calculated table, it is evaluated when the table is calculated/refreshed, not dynamically based on the visual context. That is why PREVIOUSQUARTER(DATESYTD(Dates[Date])) can return Q4 2025 instead of Q1 2026.
If you want “Last Qtr” to mean the last completed quarter relative to today, I would usually use a disconnected period slicer and apply the logic inside the measure used by the stacked column chart.
For example, create a simple slicer table with values such as “All” and “Last Qtr”. Then create a measure like this:
Sales Selected Period =
VAR SelectedPeriod =
SELECTEDVALUE ( 'Period Slicer'[Period], "All" )VAR RefDate =
TODAY()VAR CurrentQuarterStart =
DATE (
YEAR ( RefDate ),
3 * INT ( ( MONTH ( RefDate ) - 1 ) / 3 ) + 1,
1
)VAR PreviousQuarterStart =
EDATE ( CurrentQuarterStart, -3 )VAR PreviousQuarterEnd =
CurrentQuarterStart - 1RETURN
SWITCH (
SelectedPeriod,
"Last Qtr",
CALCULATE (
[Sales],
DATESBETWEEN (
Dates[Date],
PreviousQuarterStart,
PreviousQuarterEnd
)
),
[Sales]
)Then use this measure in the visual instead of the original [Sales] measure.
For example, if today is 5/22/2026, the current quarter starts on 4/1/2026, so the previous completed quarter is 1/1/2026 to 3/31/2026, which is Q1 2026.
So the main point is that the slicer should capture the user’s choice, but the actual date filter should be applied either through a proper date mapping table/relationship or through the measure used in the visual.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- 4 months ago
To identify whether a date falls within the last quarter relative to the current date, the calculation must reference the current date and then derive the date range for the previous quarter. Below is a sample calculated table that includes a column implementing this logic.
Dates = VAR _today = TODAY () VAR _startCurrentQ = DATE ( YEAR ( _today ), ( QUARTER ( _today ) - 1 ) * 3 + 1, 1 ) VAR _startLastQ = EDATE ( _startCurrentQ, -3 ) VAR _endLastQ = EOMONTH ( _startLastQ, 2 ) RETURN ADDCOLUMNS ( CALENDAR ( DATE ( 2025, 1, 1 ), _today ), "YYYYMM", FORMAT ( [Date], "YYYYMM" ), "IsLastQuarter", IF ( [Date] >= _startLastQ && [Date] <= _endLastQ, "Last Qtr" ) )
To identify whether a date falls within the last quarter relative to the current date, the calculation must reference the current date and then derive the date range for the previous quarter. Below is a sample calculated table that includes a column implementing this logic.
Dates =
VAR _today =
TODAY ()
VAR _startCurrentQ =
DATE ( YEAR ( _today ), ( QUARTER ( _today ) - 1 ) * 3 + 1, 1 )
VAR _startLastQ =
EDATE ( _startCurrentQ, -3 )
VAR _endLastQ =
EOMONTH ( _startLastQ, 2 )
RETURN
ADDCOLUMNS (
CALENDAR ( DATE ( 2025, 1, 1 ), _today ),
"YYYYMM", FORMAT ( [Date], "YYYYMM" ),
"IsLastQuarter",
IF ( [Date] >= _startLastQ && [Date] <= _endLastQ, "Last Qtr" )
)