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
Anonymous
Not applicable

Half year YTD vs previous period

Hello,

The answer to this problem was solved once before but the result isn't available anymore.

Here is the problem:

 

I need to calculate the Half year YTD of the previous period.

 

I've added a half year column to "DimDate" that computes the first half as 1 and second as 2.

 

My formula for the current half year goes like this:

Half YTD Value = CALCULATE([SalesValue],
FILTER(
        ALL(DimDate),DimDate[Date]<=MAX(DimDate[Date])),
              VALUES(DimDate[Half Year]),
DimDate[DatesWithSales]=true)

Everything works fine!

However, I can't seem to get previous period working. I've tried to use SAMEPERIODLASTYEAR, DATEADD on the ALL(DimDate),DimDate[Date]<=MAX(DimDate[Date])) with no luck. 
 
I know I'm missing something obvious.
 
Thanks!
 
 


 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , if you can have half-year start date, then you have a day of half-year, From that, you can now build it. Refer how to build it WTD. The same way you can build Half-year YTD

 

Similar logic I tested on custom Qtrs

 

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , if you can have half-year start date, then you have a day of half-year, From that, you can now build it. Refer how to build it WTD. The same way you can build Half-year YTD

 

Similar logic I tested on custom Qtrs

 

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

Anonymous
Not applicable

The answer was in front of me and it was ridicolusly simple.

In case anyone is wondering. I've modifed the formula to this:

LY Half YTD Value = CALCULATE([SalesValue],FILTER(all(DimDate),DimDate[year]<=(max(DimDate[Year])-1)),VALUES(DimDate[Half Year]),DimDate[DatesWithSales]=true)

Thanks for your help!

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.