Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have the following datesinperiod code:
Table =
CALCULATETABLE(
'Table',
DATESINPERIOD(
'Date'[Date],
PREVIOUSMONTH(MAX('Date'[Date])),
-12,
MONTH
)
)
But want the start date to be the previous month as only reporting on complete/whole months. e.g. today is 01/06/2023 so need my max date to be 31st of may 2023 and need the date to start 1st of june 2022
Solved! Go to Solution.
I managed to solve my issue using the following code:
Table =
CALCULATETABLE(
'Table',
DATESINPERIOD(
'Date'[Date],
EOMONTH(MAX('Date'[Date]), -1),
-13,
MONTH
)
)
Hi @akhaliq7
please try
Table =
CALCULATETABLE (
'Table',
FILTER (
DATESINPERIOD (
'Date'[Date],
PREVIOUSMONTH ( MAX ( 'Date'[Date] ) ),
-12,
MONTH
),
FORMAT ( 'Date'[Date], "YYMM" ) < FORMAT ( TODAY (), "YYMM" )
)
)
I managed to solve my issue using the following code:
Table =
CALCULATETABLE(
'Table',
DATESINPERIOD(
'Date'[Date],
EOMONTH(MAX('Date'[Date]), -1),
-13,
MONTH
)
)
Based on your explanation, you need to make it -12 instead of -13... Using -13 would make the range: May 1, 2022 - May 31 2023; using -12 would make it June 1, 2022 - May 31, 2023.
Just to add when I created my date table I have set max date to today()
I am getting the following error message: The first argument to 'PREVIOUSMONTH' must specify a column.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
18 | |
13 | |
12 | |
11 | |
8 |