'Power BI Compare Sales amount for today with same day last year

I have a measure showing Sales Amount for the same period year:

Sales LY = Calculate (Sum('Sales'[Product Sales]), SAMEPERIODLASTYEAR('Sales'[Payment Date].[Date]))

This measure gives me the Sales amount for same date last year. I am looking for a measure which will give me the Sales amount for same day last year. So January 1st of 2021 was a Friday. So I need it compared to the first Friday in 2020. Any assistance or guidance please!



Solution 1:[1]

You may try to check the first day of the current row year (and last year). January 1st of 2021 = Friday; January 1st of 2020 Wednesday; Diff between this two is 2. We can use this in our calculation. Example:

LastYearTheSameDay = var _firstDayOfYear = WEEKDAY(CALCULATE(MIN('Sample'[Date]), filter(ALL('Sample'), YEAR('Sample'[Date]) = YEAR(SELECTEDVALUE('Sample'[Date])))),1)
var _firstDayOfLastYear = WEEKDAY(CALCULATE(MIN('Sample'[Date]), filter(ALL('Sample'), YEAR('Sample'[Date]) = YEAR(SELECTEDVALUE('Sample'[Date]))-1)),1)
var _diff =  _firstDayOfYear - _firstDayOfLastYear
var _corrDay = DAY(SELECTEDVALUE('Sample'[Date])) + _diff
return
if(HASONEVALUE( 'Sample'[Date]), 

calculate( sum('Sample'[VAL]), filter(ALL('Sample'), 'Sample'[Date] = DATE(YEAR(SELECTEDVALUE('Sample'[Date]))-1,Month(SELECTEDVALUE('Sample'[Date])),_corrDay)  ))
, BLANK() )

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 msta42a