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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

IF statement for dates

Good morning

 

I have a table with a Start Date/Time column and and End Date/Time column. There is also a Period Start Date/Time and Period End Date/Time columns. I want to try and add another column using a IF statement.

 

I want to show if either the Start Date/Time or the End Date/Time starts or ends or fall into  the Period Start Date/Time and End Period Date/Time

 

I have manged with the formula below to see if the Start or End is in the period but not the part if it falls into it. below is the result I get. I need the second row to populate with Yes also.

 

Example 

Start Date/Time                    End Date/Time                Period Start Date/Time            Period End Date/Time         In Production

01/01/2019 04.15:00            01/01/2019 06.15:00        01/01/2019 04.00:00                 01/01/2019 04.59:59              YES

01/01/2019 04.15:00            01/01/2019 06.15:00        01/01/2019 05.00:00                 01/01/2019 05.59:59              NO

01/01/2019 04.15:00            01/01/2019 06.15:00        01/01/2019 06.00:00                 01/01/2019 06.59:59              YES

 

In Production = IF(OR(TABLE1[UTC_GAME_START] >= TABLE1[Start Of Period Date/Time]
&& TABLE1[UTC_GAME_START]<= TABLE1[End Of Period Date/Time],
TABLE1[MATCH_END_TIME]>=TABLE1[Start Of Period Date/Time]
&& TABLE1[MATCH_END_TIME]<=TABLE1[End Of Period Date/Time]), "YES", "NO")
 
 
Thanks in advance
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@v-piga-msft 

 

I have solved it

 

In Production = IF([UTC_END_TIME] > [Start Of Period Date/Time] && [UTC_START_TIME] < [End Of Period Date/Time], "YES", "NO")
 
Thanks for your time

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I still have a little confused about your logic.

It seems that the result is correct based on your logic.

1/1/2019 4:15:00 is not between  01/01/2019 05.00:00  and 01/01/2019 05.59:59 and 01/01/2019 06.15:00 is not between 01/01/2019 05.00:00  and 01/01/2019 05.59:59 either.

If it is convenient, could you describe your logic in more details so that we could help further on it?

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Cherry

 

Thanks for getting back to me.

 

I want to show in running. Start is 04:15, So that populates the 4:00:00 - 4:59:59 with Yes, the "Event" is still in running between 5:00:00 and 5:59:59. So that populates 5:00:00 and 5:59:59 with Yes. The End Date/Time is 6:15:00 so that populates 6:00:00 - 6:59:59 with Yes

 

I hope that explains properly

 

Thanks again

Joe

Anonymous
Not applicable

@v-piga-msft 

 

I have solved it

 

In Production = IF([UTC_END_TIME] > [Start Of Period Date/Time] && [UTC_START_TIME] < [End Of Period Date/Time], "YES", "NO")
 
Thanks for your time

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.