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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
cchp07
Frequent Visitor

IF Between 2 Times & Two Dates Then Date Otherwise Another Date

I have a table that pulls date, time and value. I want to create a column that puts the date  IF(time is between 7:00 a.m. and 7:00 pm. on the same day && time is between 7:00 p.m. (on the same day) and 7:00 a.m on next day, same day DATE, same day DATE -1. The snippet below provides what the end result should be. 

 Capture23.PNG

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

hi @cchp07 

Try this. You might have to convert the resulting column to date type

EndResult =
VAR CutOffTime_ = ( 1 / 24 ) * 7 // 7 AM
RETURN
    IF (
        Table1[Time] - Table1[Date] >= CutOffTime_,
        Table1[Date],
        Table1[Date] - 1
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

1 REPLY 1
AlB
Community Champion
Community Champion

hi @cchp07 

Try this. You might have to convert the resulting column to date type

EndResult =
VAR CutOffTime_ = ( 1 / 24 ) * 7 // 7 AM
RETURN
    IF (
        Table1[Time] - Table1[Date] >= CutOffTime_,
        Table1[Date],
        Table1[Date] - 1
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.