cancel
Showing results for
Did you mean:
Helper III

## 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.

1 ACCEPTED SOLUTION
Super User

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.

9 REPLIES 9
Super User

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.

Helper III

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.

Super User

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.

Helper III

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

Great Salute :).

Super User

@shankarshiva70

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
Helper III

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

Super User

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

Helper III

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

Super User

Hi @shankarshiva70 ,

Can you try this:

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

Thanks

Announcements

#### The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

#### Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

#### Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors