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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Jitmondo
Helper III
Helper III

Getting 2 years back total !

Hi All,

 

something simple I think but can't get it to work.

 

I have a graph where I am showing last years won deals :

Last Year Closed Won = TOTALYTD([Closed Won Weighted Pipeline],SAMEPERIODLASTYEAR(Dates[Date]))
this works fine and is shown as a line.
 
my current measurs and visuals are dynamic and change with year selector slicer so this new measure would need to be too.
 
Is there a way to write a measure that shows the year before that ?
 
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Jitmondo ,

 

You could try use edate() function. Please check this measure.

measure =

var _date =selectedvalue('date'[date])

return
calculate(sum([value]),filter(allselected('table'),'table'[date]>=date(year(_date)-2,1,1)&&'table'[date]<=edate(_date,-24)))

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Jitmondo ,

 

You could try use edate() function. Please check this measure.

measure =

var _date =selectedvalue('date'[date])

return
calculate(sum([value]),filter(allselected('table'),'table'[date]>=date(year(_date)-2,1,1)&&'table'[date]<=edate(_date,-24)))

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Jitmondo
Helper III
Helper III

thanks for replying, my last year (sameperiodlast year) works fine. I am trying to see if there is a way to alter this measure or a new measure to show the year before last...

Anonymous
Not applicable

Please check PARALELLPERIOD function then, it should work 🙂 

 

PARALLELPERIOD function (DAX) - DAX | Microsoft Docs

 

Your interval should be -2 for example:

CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PARALLELPERIOD(DateTime[DateKey],-2,year)) 

 

Anonymous
Not applicable

Good morning @Jitmondo 

 

Please check this previus answer and see if they work for you: 

Solved: TOTALYTD with SAMEPERIODLASTYEAR not working as ex... - Microsoft Power BI Community

If you have a slicer with the dates they should work.

 

Regards!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.