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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Force the end of the YTD on certain measure

Hi everyone,

 

I have a model with two fact table and a calendar. 

FactTable1 goes until 31/12/2021

FactTable2 goes until 31/08/2021

The calendar goes until 31/12/2021

 

I'm calculating some YTD value (with DATESYTD(Calendar[Date]) ) on FactTable2 but by default the YTD is calculated on 31/12/2021, so if i want the real value i have to use a slicer and filter on August which is not optimal in my case. 

 

I wanted to force the YTD to the last date registered in FactTable2 for measure which read FactTable2 and not to the lastdate of the Calendar.

 

Something like this but which is working :

 

RealMaxDate = lastdate(FactTable2[Date])

 

YTD = CALCULATE([Amount],DATESYTD(Calendar[Date]),FILTER(Calendar,Calendar[Date]<=RealMaxDate))

 

Thank you very much,

Best regards

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I think, one of the ways to create it is to use KEEPFILTERS function.

 

Picture1.png

 

Qty two YTD fix : =
VAR twomaxdate =
MAXX ( FILTER ( ALL ( Sales_two ), Sales_two[Qty] <> 0 ), Sales_two[Date] )
RETURN
CALCULATE (
[Qty two YTD :],
KEEPFILTERS ( FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= twomaxdate ) )
)
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

It's working Jihwan_Kim, thank you 😉

In the mean time i managed to find another solution which was working im my case two if someone is interested :

In my calendar table i added two column :

LastDateFactTable1 = Calendar[Date] <= max(FactTable1[Date])

LastDateFactTable2 = Calendar[Date] <= max(FactTable2[Date])

 

Then in my YTD measure i use those column as a filter, like this :

MeasureFact1 YTD = CALCULATE([MeasureFact1],CALCULATETABLE(DATESYTD(Calendar[Date],Calendar[LastDateFactTable1]=TRUE))

MeasureFact2 YTD = CALCULATE([MeasureFact2],CALCULATETABLE(DATESYTD(Calendar[Date],Calendar[LastDateFactTable2]=TRUE))

Jihwan_Kim
Super User
Super User

Hi,

I think, one of the ways to create it is to use KEEPFILTERS function.

 

Picture1.png

 

Qty two YTD fix : =
VAR twomaxdate =
MAXX ( FILTER ( ALL ( Sales_two ), Sales_two[Qty] <> 0 ), Sales_two[Date] )
RETURN
CALCULATE (
[Qty two YTD :],
KEEPFILTERS ( FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= twomaxdate ) )
)
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.