Forum Discussion
previous year calculation with time filter
- 9 years ago
Hi RMV
When you created your date table did you create the relationships?
I created the following measures based on your dataset.
My Amount = SUM(Table1[Amount]) YTD = TOTALYTD([My Amount],'Date'[Calendar Date]) Previous Yr My Amount = CALCULATE([My Amount],PREVIOUSYEAR('Date'[Calendar Date]))Which then gave me the following correct output.
Hi,
I have this difficulty in applying a correct formula.
I'm trying to apply DAX formula to get the previous year calculation, while I also have Month Slicer applied for my financial report.
What I have is transaction table, the example is follow
| Date | Amount |
| 1-Jan-16 | 1000 |
| 5-Jan-16 | 500 |
| 2-Feb-16 | 400 |
| 11-Feb-16 | 1700 |
| 2-Jan-17 | 700 |
| 10-Jan-17 | 500 |
| 20-Jan-17 | 1000 |
| 3-Feb-16 | 2000 |
In the page where I add the visualization, I have a Month slicer. and the formula I tried to apply is:
Amount YTD Previous Year = CALCULATE(SUM(GLEntry_all[Amount_]),FILTER(DateCalendar,AND(DateCalendar[Date]>=DATE(YEAR(TODAY())-1,1,1),DateCalendar[Date]<=DATE(YEAR(TODAY())-1,MONTH(MAX(DateCalendar[Date])),DAY(ENDOFMONTH(DateCalendar[Date]))))))
But this formula returns blank amount. I'm guessing this is because of the Month slicer applied is for 2017.
For the information, I don't have any other filter in the visual nor page nor report.
I tried to use SAMEPERIODLASTYEAR or PREVIOUSYEAR formula, but I guess these work only for unique calendar date (?)
I need help, what goes wrong with my formula, and what solution I need to apply.
Thanks.