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

Last year calculations

Hi guys,

 

I am stucking on last year same period calculations.

like we are in 2021 so this year calculation period will be-  1st jan21 to 3rd oct 2021

and Last year same period will be 1st Jan20-3rd Oct2020- how can I get this result

 

I have tried- calculate(sum(sales),sameperiodlastyear(date[date])- showing incorrect result.

Please help me on this.

@Tanushree_Kapse @amitchandak 

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Try this:

Measure=
Var _T = Today()
Var _LYS = date(year(_T)-1,01,01)
Var _LYF = date(year(_T)-1,month(_T),day(_T))
Return
calculate(sum(sales),filter(table,date[date]>=_LYS &&date[date]<=_LYF ))

 

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

Appreciate your Kudos!!

 

View solution in original post

9 REPLIES 9
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

Measure=
Var _T = Today()
Var _LYS = date(year(_T)-1,01,01)
Var _LYF = date(year(_T)-1,month(_T)+1,01)-1
Return
calculate(sum(sales),filter(table,date[date]>=_LYS &&date[date]<=_LYF ))

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

Appreciate your Kudos!!



 

Anonymous
Not applicable

Thanks,

 

It is giving jan20-Oct20 data but I am trying to find out 1st Jan20-3rd Oct 20.

only we have to rectrict the date range.

Hi @Anonymous 

 

Try this:

Measure=
Var _T = Today()
Var _LYS = date(year(_T)-1,01,01)
Var _LYF = date(year(_T)-1,month(_T),day(_T))
Return
calculate(sum(sales),filter(table,date[date]>=_LYS &&date[date]<=_LYF ))

 

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

Appreciate your Kudos!!

 

Anonymous
Not applicable

@VahidDM 

Thanks. Now got my anser what I was looking for.

Great Salute :).

Fowmy
Super User
Super User

@Anonymous 

Your formula seems okay, make sure in your date slicer you have selected 1st jan21 to 3rd oct 2021

 

Measure = CALCULATE ( SUM ( sales[column] ), SAMEPERIODLASTYEAR ( date[date] ) )

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hi,

Thanks for quick reply.

Actually I dnot want to select any date slice point. have to show in formala.

Request you to please reshare formula please.

Thanks

Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

Try thi measure:
Lastperiod=  Calculate(Totalytd(Sum(sales),date[date]) ,Parallelperiod(date[date], -12, Month))

Mark this as a solution if I answered your question. Kudos are always appreciated.
Thanks

Anonymous
Not applicable

Hi,

Thanks for quick reply

But This formula is not showing correct result as trying to match manual.

Request you can you please check once nd reply please

Thanks

Hi @Anonymous ,

Can you try this:

YTDSales= TOTALYTD(SUM(Sales), DATESYTD(date[date], TODAY()))
PYTDSles= CALCULATE(YTDSales, DATESYTD(date[date], TODAY()-1))

 

Thanks

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.