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

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

Reply
astallings
Regular Visitor

Join Datetime field on table with Datetime range (Start and End Datetime)

I've got an MSSQL table [incidents] with a datetime field, and a mysql table [schedule] which contains all employee shifts worked with start (datetime) and end (datetime) fields.

 

 

 

 

I'm trying to build a dashboard to list incomplete incident reports. When an incident is clicked on I'd like to list everyone who was working during the incident.

 

 

Can this be done within Power BI?

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@astallings,

 

You may drag measure below to Table2. It takes advantage of Show Categories With No Data.

Measure =
VAR dt =
    SELECTEDVALUE ( Table1[dt] )
VAR st =
    SELECTEDVALUE ( Table2[st] )
VAR et =
    SELECTEDVALUE ( Table2[et] )
RETURN
    IF ( st <= dt && dt <= et, 1 )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@astallings,

 

You may drag measure below to Table2. It takes advantage of Show Categories With No Data.

Measure =
VAR dt =
    SELECTEDVALUE ( Table1[dt] )
VAR st =
    SELECTEDVALUE ( Table2[st] )
VAR et =
    SELECTEDVALUE ( Table2[et] )
RETURN
    IF ( st <= dt && dt <= et, 1 )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks! That worked great.

 

 

a little confused about this part of the code. Wouldn't those 2 variables always be NULL?

 

VAR st = SELECTEDVALUE ( Table2[st] )
VAR et = SELECTEDVALUE ( Table2[et] )

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.