Forum Discussion
jfranco
2 years agoFrequent Visitor
DAX Calculated Column - Value from a same date previous year
Hello and Good Morning. I have another question from the knowledge base. I have the following table: ID Location Date Production A North 01/01/2024 10 B North 01/01/2024 ...
- 2 years ago
Thank you Anonymous
Thank you!
Almost but not quite.
I ended up creating two columns
M = Month(Table[Date])
PY = Year(Table[Date])
and then using a variation of your DAX code :
CALCULATE (SUM([Production)]),FILTER(ALL(Table),Table[ID]=EARLIER(Table[ID])&& Table[Location] = EARLIER(Table[Location])&& Month(Table[Date]) = Earlier(Table[M])&& Year(Table[Date]) = EARLIER(Table[PY]) )))Gracias
Roger
Anonymous
2 years agoNot applicable
Hi jfranco
Please try the following dax:
PreviousYearProduction =
CALCULATE(
SUM('Table'[Production]),
FILTER(
ALL('Table'),
'Table'[ID] = EARLIER('Table'[ID]) &&
'Table'[Location] = EARLIER('Table'[Location]) &&
'Table'[Date] = DATEADD('Table'[Date], -1, YEAR)
)
)
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jfranco
2 years agoFrequent Visitor
Thank you Anonymous
Thank you!
Almost but not quite.
I ended up creating two columns
M = Month(Table[Date])
PY = Year(Table[Date])
and then using a variation of your DAX code :
CALCULATE (SUM([Production)]),
FILTER(ALL(Table),
Table[ID]=EARLIER(Table[ID])
&& Table[Location] = EARLIER(Table[Location])
&& Month(Table[Date]) = Earlier(Table[M])
&& Year(Table[Date]) = EARLIER(Table[PY]) )))
Gracias
Roger