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

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

Reply
cottrera
Post Prodigy
Post Prodigy

Dax to count if time = min & max time on second table

Hi 

I have a data table (table 1) with names , max times and dates.  I have created a new table by entering data. This contains order, finish description, min time and max time.

 

Table 1

NameMax TimeAppointment Date
Joshua15:57:2316/03/2021
Tony15:57:2525/03/2021
Troy16:00:0010/04/2021
David17:00:2320/04/2021
Derek17:00:2316/03/2021
Tony17:30:4226/03/2021
Mark17:56:1726/04/2021
Gary17:56:3101/04/2021
Paul17:57:1718/03/2021
Harry17:57:5731/03/2021
Gary17:58:5024/03/2021
Jake18:00:0016/03/2021
John18:00:2202/04/2021
Owen18:00:3523/03/2021
Ashley19:55:3816/04/2021
David19:57:2315/03/2021
David19:57:4225/03/2021
Christopher19:57:4309/04/2021

 

Table 2

OrderFinishMinMaxDAX Expected Result
1Before 16:0000:00:0016:00:002
2Between 16:00-17:0016:00:0017:00:001
3Between 17:00-17:3017:00:0017:00:302
4Between 17:30-18:0017:30:0018:00:006
5Late finish / OHH after 18:0018:00:0000:00:007

 

I would like a DAX function to count if the times from table 1 fit the Min & max criteria of table 2

 

thank you

 

RIchard

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @cottrera 

Please correct me if I wrongly understood your question.

Please check the below picture and measure whether it is what you are looking for.

 

Picture1.png

 

Result Measure =
COUNTROWS (
FILTER (
Table1,
Table1[Max Time] >= SELECTEDVALUE ( Table2[Min] )
&& Table1[Max Time] < SELECTEDVALUE ( Table2[Max] )
)
)
 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi, @cottrera 

Please correct me if I wrongly understood your question.

Please check the below picture and measure whether it is what you are looking for.

 

Picture1.png

 

Result Measure =
COUNTROWS (
FILTER (
Table1,
Table1[Max Time] >= SELECTEDVALUE ( Table2[Min] )
&& Table1[Max Time] < SELECTEDVALUE ( Table2[Max] )
)
)
 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
cottrera
Post Prodigy
Post Prodigy

Hi thank you for your quick response. I added the Dax function to table 2. no errors but the result seems a little strange

 

I only received a result for one of the lines in table 2 and none of the other lines.

can you please advise. 

thanks 

RIchard

amitchandak
Super User
Super User

@cottrera , new column in table 2

 

countx(filter(table1, table1[Max Time] >= Table2[Min] && table1[Max Time] <= Table2[Max]),table1[Name])

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

Helpful resources

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

Top Solution Authors
Top Kudoed Authors