Forum Discussion
SAME PERIOD LAST YEAR
- 4 years ago
Hi vijay273162
If you are using dates from a fact table, try this way,
column = VAR _date = EDATE ( 'Table'[Date], -12 ) RETURN CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] >= _date && 'Table'[Date] < EARLIER ( 'Table'[Date] ) ) )If you want to create measure, then try this
LY = CALCULATE(SUM('Table'[Sales]),SAMEPERIODLASTYEAR('Table'[Date]))Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi vijay273162
SAMEPERIODLASTYEAR - Returns a table that contains a column of dates shifted one year back in time from the dates specified in date column.
Thus, you can't use it in the column.
you can achieve this using the below steps:
1- For the current date - create 1 concatenated column of date removing '/'. you can add a custom column which says:
Use CONCAT function : eg - =Concat(Month(Date),Year(Date))
2- For the last year's date - create another concatenated column
eg- Concat(Month(Date),year(Date)-1)
3- Return the values of sales by matching column 2(Concatenation of Last year's date) with Column 1(Concatenation of current date).
If you need the exact DAX, then please share sample data with me.
If this helps, then please mark it as a solution and hit the thumbs up.
Regards,
TruptiS
- Anonymous4 years agoNot applicable
Perfect
- vijay2731624 years ago
Helper III
Hi,
This is how I got the result for Same Period Last Year using calculated column