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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dmgebauer
Frequent Visitor

How to identify multiple dates in 1 table to multiple pairs of dates in a 2nd table with conditions

I have two tables, 'TeeTimes' and 'Closures' with data that I would like to compare.

The "Budget Tee Date" in the 'TeeTime' table to see if it falls between the 'Closure' tables "Close Date" and "Open Date". Then put the value of "Closure Type" from the 'Closure' table into the "Open/Close" column of the 'TeeTimes' table or simply the text value "Open" if no conflicts with the closures.

 

Department is a common field in both tables. 

 

Table views

Tables_Markup.png

 

 

 

 

 

 

 

Relationship

Tree_Markup.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks in advance!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@dmgebauer Maybe:

 

Open/Close Column =
  VAR __Dept = [Dept]
  VAR __Course = [Course]
  VAR __BudgetTeeDate = [Budget Tee Date]
  VAR __Table = FILTER(ALL('Closures'), __BudgetTeeDate >= [Close Date] && __BudgetTeeDate <= [Open Date])
  VAR __ClosureType = MAXX(__Table, [Closure Type])
  VAR __Result = IF( __ClosureType = BLANK(), "Open", __ClosureType)
RETURN
  __Result

  
  

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@dmgebauer Maybe:

 

Open/Close Column =
  VAR __Dept = [Dept]
  VAR __Course = [Course]
  VAR __BudgetTeeDate = [Budget Tee Date]
  VAR __Table = FILTER(ALL('Closures'), __BudgetTeeDate >= [Close Date] && __BudgetTeeDate <= [Open Date])
  VAR __ClosureType = MAXX(__Table, [Closure Type])
  VAR __Result = IF( __ClosureType = BLANK(), "Open", __ClosureType)
RETURN
  __Result

  
  

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  Thank you!!

Close! but I will need to have the result based on the matching departments by each specific closure date range. Current formula seems to be applying a closure to all departments not the matching department.

department no match.png

Looks like it is working with this update

Open/Closed =
  VAR __Dept = [Dept]
  VAR __Course = [CourseName]
  VAR __BudgetTeeDate = [Budget Tee Date]
  VAR __Table = FILTER(ALL('Closures'), __Dept = Closures[Dept] && __BudgetTeeDate >= [Close Date] && __BudgetTeeDate <= [Open Date])
  VAR __ClosureType = MAXX(__Table, [Closure Type])
  VAR __Result = IF( __ClosureType = BLANK(), "Open", __ClosureType)
RETURN
  __Result

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.