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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
alsolok
Helper II
Helper II

TOTALYTD with SAMEPERIODLASTYEAR not working

Hello everyone,

 

I have sales data for all of 2021 and through October for 2022. I'm trying to get sales from 2021 through to the latest date in 2022.

For a start, I tried this method:

 

Sales YTD = TOTALYTD(SUM('Sales'[Sales Amount]), 'Date'[Date])

-- that sums up the whole year 2022

YTD Sales LY = CALCULATE([YTD Sales], SAMEPERIODLASTYEAR('Date'[Date] ))

-- The latter returns me the sum of all the rows of 2021

The 2nd method, I tried this other rule:

Sales = SUM('Sales'[Sales Amount])

Sales YTD = TOTALYTD(Sales, 'Date'[Date])

Sales LY = CALCULATE([Sales], SAMEPERIODLASTYEAR('Date'[Date] ))

Sales YTD = TOTALYTD([Sales LY]), 'Date'[Date])

And a 3rd too

Sales = CALCULATE(SUM('Sales'[Sales Amount]), DATESYTD('Date'[Date]))

Sales LY YTD = CALCULATE([Sales], SAMEPERIODLASTYEAR('Date'[Date] ))

 

alsolok_0-1672744915989.png

 

 

but unfortunately both don't work.

help me

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @alsolok ,

 

What's your expected result? Could

Sample data.

vstephenmsft_1-1672990001684.png

And I tried your first method, it seems work.

vstephenmsft_0-1672989987603.png

If not, please tell me what the correct expected result should look like.

 

 

 

 

Best Regards,

Stephen Tao

 

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

negi007
Community Champion
Community Champion

@alsolok you can apply YTD date filter to show only YTD dates. if you have date table, you can create below calc column

Days_for_Year = DATEDIFF(STARTOFYEAR('Calendar'[Date]),'Calendar'[Date],DAY)+1

 
YTD_Days = if ('Calendar'[Days_for_Year] < LOOKUPVALUE('Calendar'[Days_for_Year],'Calendar'[Date],TODAY()-1), "YTD", "Remaining")
 
negi007_0-1672747718968.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.