Forum Discussion

os_ca's avatar
os_ca
Frequent Visitor
5 years ago
Solved

PreviousYear() Function doesn't work

I can't figure out why PreviousYear() function doesn't work. What is worng with my formula with PreviousYear()?

 

There are colums in a table in a report.

Product Category | Calendar Year | Total Sales | Previous Year Sales

 

1. It doesn't work. It returns blank.

previous year amount 2 =
   CALCULATE(sum(FactInternetSales[SalesAmount]), PREVIOUSYEAR(DimDate[FullDateAlternateKey]))

 

2. It works.

previous year amount =
   CALCULATE(sum(FactInternetSales[SalesAmount]), FILTER(all(DimDate), DimDate[CalendarYear] = SELECTEDVALUE(DimDate[CalendarYear])-1))
  • Is your Date table "Marked as Date Table"?  You are using the alternatekey column in DimDate.  Is that the one that was validated when you made the date table?

     

    Regards,

    Pat

3 Replies