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
Anonymous
Not applicable

Previous Year sales by choosing slicer

Hi floks,
Here I am confused with SAMEPERIODLASTYEAR, beacuse i worte a DAX as
LastYearSales =CALCULATE(SUM('Shipped Order Analysis'[TotalSales]),SAMEPERIODLASTYEAR('Date'[Date]))

After that I perfectly got previous year sale amount when i choose  date slicer as 2019-12-01 to today,
But When I choose date slicer as 2018-12-01 to today, it gives previous two year sales amount (like 2017-12-01 to 2019-10-09).


Here my expected result is to be last one year only have to shown.
I try and tired. can any body help me to comeup this.


Thanks in advance,
Sivanesan

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

You can use dateadd() like @ AlB mentioned to create a measure like this:

Last year sales =
CALCULATE ( SUM ( 'Table'[Sales] ), DATEADD ( 'Table'[date], -1, YEAR ) )

last year.png

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @Anonymous 

That's how SAMEPERIODLATYEAR( ) works. Check the definition at  https://dax.guide/sameperiodlastyear/

Internally SAMEPERIODLASTYEAR corresponds to the following call of DATEADD:
  DATEADD ( <Dates>, -1, YEAR )

If you want a different behaviour you can do it with the appropriate FILTER( ) on Date, selecting the period you're interested in

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hi @AlB ,
Thank you for your response. Now I clearly understand SAMEPERIODLASTYEAR() functionality.
Can you please suggest me a DAX with filter for only previous year.

Thanks in advance ,
Sivanesan

Hi @Anonymous ,

You can use dateadd() like @ AlB mentioned to create a measure like this:

Last year sales =
CALCULATE ( SUM ( 'Table'[Sales] ), DATEADD ( 'Table'[date], -1, YEAR ) )

last year.png

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors