Forum Discussion
DateAdd and SamePeriodLastYear Returning Blank Values
- 6 years ago
Hi Anonymous ,
If you have a date table, your measure is correct, but there is a little detail, maybe you ignore, please refer the following steps,
1. Create a one-to-many relationship between your table and date table.
2. Then we create a measure like yours.
Sales LY Test1 = CALCULATE(SUM('Table'[Sales]), SAMEPERIODLASTYEAR('Date'[Date]))3. At last we put the ‘Date’[date] to the visual, the result like this,
Or if you don’t have a date table, we can create a new measure to meet your requirement.
Sales LY Test 2 = var _currentyear = MAX('Table'[Year]) var _lastdate = DATE(_currentyear-1,MONTH(MAX('Table'[Time Period])),DAY(MAX('Table'[Time Period]))) return CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),'Table'[Time Period]=_lastdate))If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, I have the same problem and have tried multiple formulas but still showing blank.
I have a Table having KPI values, and another one is a calendar table. i am trying to show last year value but no luck
I have tried this: