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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smpatric
Frequent Visitor

TOTALYTD including entire month with SAMEPERIODLASTYEAR

Hello,

 

I'm trying to do a YTD comparison between this year and last. I have two formulas below, one for the Current Year and one for the Prior Year. For some reason, the Current Year calculation is working correctly, but when I apply SAMEPERIODLASTYEAR for the Prior Year calculation, the dates for the entire month of January are brought in. Here are my forumlas:

 

# Deals YTD = TOTALYTD(SUM('Deal Activity'[Count]),'Date'[Date])

And for the Prior Year YTD:

 

# Deals PYD = CALCULATE([# Deals YTD],SAMEPERIODLASTYEAR('Date'[Date]))

As noted, the second formula is calculating a Total for 1/1/2018-1/31/2018, but I only want it to show 1/1/2018-1/17/2018. Does anyone know why it would bring in the whole month?

 

Thanks

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @smpatric,

 

If you only want to get the same period of the dates. We can take the following steps.

 

1. Create a new date table and create relationship between it and the fact table.

 

date = CALENDAR(MIN('Deal Activity'[date]),MAX('Deal Activity'[date]))
Year = YEAR('date'[Date])

2. Create a measure as below.

 

Previsou = TOTALYTD(SUM('Deal Activity'[Count]),DATEADD('date'[Date],-365,DAY))

Capture.PNG

I guess that should be the issue of the way creating date table. So I create a new one here to work on it.

 

For more details, please check the pbix as attached.

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @smpatric,

 

If you only want to get the same period of the dates. We can take the following steps.

 

1. Create a new date table and create relationship between it and the fact table.

 

date = CALENDAR(MIN('Deal Activity'[date]),MAX('Deal Activity'[date]))
Year = YEAR('date'[Date])

2. Create a measure as below.

 

Previsou = TOTALYTD(SUM('Deal Activity'[Count]),DATEADD('date'[Date],-365,DAY))

Capture.PNG

I guess that should be the issue of the way creating date table. So I create a new one here to work on it.

 

For more details, please check the pbix as attached.

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks Frank. Should have thought of that, but worked like a charm!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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