Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
os_ca
Frequent Visitor

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))
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

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





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
os_ca
Frequent Visitor

Thanks all guys for helping me. sorry I can't speak Spanish and no idea how my post ended up here.

English version: https://community.powerbi.com/t5/Desktop/PreviousYear-Function-doesn-t-work/m-p/1484927#M617176

Greg_Deckler
Community Champion
Community Champion

@os_ca You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
mahoneypat
Microsoft Employee
Microsoft Employee

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





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors