Forum Discussion
Get previous YYYY-MM value based on existing YYYY-MM value
- 5 years ago
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
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:
- blynchdata5 years ago
Resolver I
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!