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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
TomBI
Frequent Visitor

DATESYTD not working on SWITCH with logical test based on time

I am encountering a problem with a DATESYTD on a time based SWITCH measure that I am writing. 

 

Situation:

- I have a measure for my Actuals

- I have a measure for my Forecast

- I have a SWITCH measure that looks at actuals when the week is in the past (based on the WeekIndex_Nr), and at the forecast when the week is in the future

- I want to create a measure that calculates the YTD based on the SWITCH measure

 

Used measures:

 

Actuals = SUM( Fact_Sales[Quantity] )
Forecast = SUM( Fact_Forecast[Quantity] )
Switch ACT/FCST =

SWITCH( TRUE() ,
    SELECTEDVALUE( Dim_Date[WeekIndex_Nr] ) >= 0 , [Forecast] , [Actuals]
)
YTD on Switch ACT/FCST =

CALCULATE(
    [Switch ACT/FCST] ,
    DATESYTD(Dim_Date[Date] )
)

 

Problem: 

I use the DATESYTD measure to calculate the YTD value. Usually this always works, but when I apply it on the SWITCH as described above, the accumulated values are ONLY those of the Forecast, and not of the Actuals. 

 

Result:

 

DATESYTD.png

 

Can anyone explain why this is happening and how to solve it? 

 

Thanks a lot! 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@TomBI , Try like

 

CALCULATE(
Sumx(values( Dim_Date[WeekIndex_Nr] ),[Switch ACT/FCST] ) ,
DATESYTD(Dim_Date[Date] )
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@TomBI , Try like

 

CALCULATE(
Sumx(values( Dim_Date[WeekIndex_Nr] ),[Switch ACT/FCST] ) ,
DATESYTD(Dim_Date[Date] )
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Great! Works perfectly. Can you explain why? 

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric 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.

Users online (25)