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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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