Forum Discussion
Anonymous
6 years agoNot applicable
SAMEPERIODLASTYEAR in a Calculated Column
Hi, I need the Sales Last Year (Sales LY) as a Calculated Column in my Data Base so I can compare Sales vs Sales LY in a Scatter Chart by Peer. My problem is that when I apply the SAMEPERIODLASTYEA...
mahoneypat
6 years agoMicrosoft Employee
In your measure, you are trying to get the Sum for the date one year ago. If that is what you are looking for (vs. getting a sum over a broader previous period like quarter), this expression would do it too:
Sales LY =
VAR ayearago =
DATE ( YEAR ( Append1[Date]) - 1, MONTH ( Append1[Date] ), DAY ( Append1[Date] ) )
RETURN
CALCULATE (
SUM ( Append1[Value] ),
ALL ( Append1 ),
Append1[Date] = ayearago,
VALUES ( Append1[Peer] )
)
I am not sure what columns you need to keep constant (Peer, Source, etc.) so you can add/replace a Values() term like this for each one to keep the same for the calculation.
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
Anonymous
3 years agoNot applicable
This was the only resolution from this page that resolved my issue.