Forum Discussion

jfranco's avatar
jfranco
Frequent Visitor
2 years ago
Solved

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 ...
  • jfranco's avatar
    jfranco
    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