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
afree
Frequent Visitor

Need Help with DAX 2-Day Lag Formula return different data sources based on future vs. past

Hi,

I am trying to create a DAX formula that will return hours depending on the day. Please help! I am very stuck.

 

For past dates before TODAY and YESTERDAY, I want to return the data from "Actual Hours" measure/column.

For TODAY, YESTERDAY and FUTURE DAYS, I want to return the data from "Scheduled Hours" measure/column.

 

I am currently using the below formula but it is not bringing in "Scheduled Hours" for today and future. The hours return for past dates before Yesterday and Today are incorrect. I am comparing this data in a table matrix by bringing in Actual Hours and Scheduled Hours side by side.

 

2 Day Lag Hours =
VAR CurrentDate = SELECTEDVALUE('Tables- Dates'[Date])
VAR Result =
    SWITCH(
        TRUE(),
        CurrentDate < TODAY() - 1,[Actual Hours], //Past: Actual Hours Measure
        CurrentDate <= TODAY(), [STAR Scheduled Hours], //Today and Yesterday: Scheduled Hours Measure
        CurrentDate > TODAY(), [STAR Scheduled Hours] //Future: Scheduled Hours Measure
    )
RETURN
Result
 
Thank you!
2 REPLIES 2
technolog
Super User
Super User

I hope this message finds you well. I've noticed that this solution remain unresolved. If any of you have managed to find a resolution to the issue, I kindly request that you share your solution for the benefit of the entire community. Alternatively, if you're still facing challenges, please do let us know as well.

Your insights and updates will greatly assist others who might be encountering the same challenge.

some_bih
Super User
Super User

Hi @afree I am courious, isn't YESTERDAY already less than TODAY? So you only need reference to <TODAY and second scenario >TODAY. Hope this help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.