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.
My dataset has rows by year and month. It has a related calendar table. In my reporting I am using the calendar table YYYY-MM value.
The calendar table also has a proper date column for the last day of the month. I can create a previous year date using:
Now I want to create a previous year value measure so I did the following:
Solved! Go to Solution.
@009co , As long as YYYYMM is coming from the calendar table, that should not give issue.
Measure is correct
Actual PY = CALCULATE([Actual],DATEADD('Calendar'[Date],-1,YEAR))
Check -
calendar table is marked as date table
It has previous year dates in the date column. I doubt you need date PY
So for this year date column should have date for 2020 too
The Fact Date should not have any timestamp
Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw
My original date table and fact table relationship was based on an integer representation of a date eg 20210101 however creating a new calculated column that was a proper date in both of these tables and using that new proper date for the relationship made time intelligence work properly.
Sometimes when this happens to me, I bypass the DATEADD() function.
I'll create a variable:
PY = MAX("Calendar Year Number in Date Dimension Table") - 1
Comment: So this takes the current Year Number in the context, and subtracts 1 manually.
Then in my measure:
Measure = CALCULATE([Actual], "Calendar Year Number in Date Dimension Table" = PY)
This can often work for me, but it does require you have a Year Number in your Date Dimension.
Interesting. Gave this a try but am getting following error when doing:
Did I do this as you explained? It was clear exactly what you meant by "Calendar Year Number in Date Dimension Table"?
Thanks
I'm not sure there should be square brackets around the PY variable in your measure as it may think it's a column or a measure. I've confirmed this way does work for me.
I'm looking at some other ways that I've done this and I found that it works well, using CalculateTable() as a kind of filter within the CALCULATE() of [Actual].
Measure = CALCULATE (
[Actual],
CALCULATETABLE ( DATEADD ( 'Date Dimension'[Date_Formatted_Column], -1, YEAR ) )
)
RE first suggestion, was it to create a new column with a variable and result to be returned as follows? This didn't create any errors, but was just blank:
Measure =
VAR
PY = FORMAT(DATEADD('Calendar'[Date],-1,YEAR), "YYYY")
RETURN
CALCULATE([Actual], 'Calendar'[Year] = PY)
RE second suggestion, it just returns the current year actual value:
Apologies, I didn't know you were trying to make a column, I thought it was a measure.
I will bow out here as I am unsure!
Hey thanks for answer @amitchandak
Check -
calendar table is marked as date table - It wasn't, I didn't know this so thanks for teaching me something new. However, I am not able to mark my table as date table. I get message that claims there are gaps in dates ... I suspect it is because table doesn't have complete years even though it spans multiple years.
It has previous year dates in the date column. I doubt you need date PY - it did have all required dates past and present
The Fact Date should not have any timestamp - the table comes from SQL server db, and is formatted as text. So this might be problem too.
@009co , As long as YYYYMM is coming from the calendar table, that should not give issue.
Measure is correct
Actual PY = CALCULATE([Actual],DATEADD('Calendar'[Date],-1,YEAR))
Check -
calendar table is marked as date table
It has previous year dates in the date column. I doubt you need date PY
So for this year date column should have date for 2020 too
The Fact Date should not have any timestamp
Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw
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 |
---|---|
11 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
9 |