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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors