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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlanGroskreutz
Frequent Visitor

How to use multiple tables in single filter in DAX?

Hello, I'm trying to work with a strangely formated table and am having some trouble with creating a calculated column.

I have a table that shows the arrival times for aircraft at an airport (arrivals).  I have another table that has the hourly capacity limits for that runway (capacity).  What I want to add is a calculated column in the arrivals table that shows what the capacity is for that time.

The problem is the capacity figures are shown in ranges. It has FromDate, ToDate, FromTime, ToTime as columns.  Here are some samples of the two tables.

Arrivals

ALDTLeaderDay of the weekALDTLeaderDateKeyALDTLeaderTimeKeyCapacity
2-1-17 6:262201701029062634 
2-1-17 6:402201701029064046 
2-1-17 6:432201701029064355 
2-1-17 6:482201701029064804 
2-1-17 7:092201701029070901 
2-1-17 7:112201701029071139 
2-1-17 7:132201701029071306 

 

Capacity

fromDateKeytoDateKeyfromTimeKeytoTimeKeydayOfTheWeekoperationTypecapacity
2017011020170205900000090459001LLEGADAS24
2017011020170205900000090459002LLEGADAS24
2017011020170205900000090459003LLEGADAS24
2017011020170205900000090459004LLEGADAS24
2017011020170205900000090459005LLEGADAS24
2017011020170205900000090459006LLEGADAS24
2017011020170205900000090459007LLEGADAS24
2017011020170205905000090559001LLEGADAS18
2017011020170205905000090559002LLEGADAS18
2017011020170205905000090559003LLEGADAS18
2017011020170205905000090559004LLEGADAS18
2017011020170205905000090559005LLEGADAS18
2017011020170205905000090559006LLEGADAS18

 

The 9s in front of the time keys are a way for the leading zeroes to not get lost, so that is not an error.

 

Anyway, what I'd like to do is for every row in the arrival table, look at the date and time of arrival (DateKey, TimeKey) and perform a filtered lookup on the capacity table to find the capacity for that ALDT time.

 

I was thinking somwething along the lines of 

Calculated column=CALCULATE(

FILTER(

‘Capacity’(DayOfWeek)  =  ’arrivals(day of week),

‘Capacity’(fromDateKey)  <  ‘arrivals(DateKey),

‘Capacity’(toDateKey)  >  ‘arrivals(DateKey),

‘Capacity’(fromTimeKey)  <  ‘arrivals(TimeKey),

‘Capacity’(toTimeKey)  <  ‘arrivals(TimeKey) ),

                LOOKUPVALUE(‘Capacity’(capacity))

)

 

Thanks for any guidance,

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @AlanGroskreutz,

I try to figure out a solution for you. But we can not create n:n relationship between two tables. You want to filter ‘Capacity’(DayOfWeek)  =  ’arrivals(day of week), there should be a relationship based on DayOfWeek, while there is no unique value for two columns of the two table. For example, there are mutiple 2 day of week rows in 'Arrivals' and mutiple 2 day of week rows in 'Capacity', we can not decide which row is used to other filters: 

 

‘Capacity’(fromDateKey)  <  ‘arrivals(DateKey),

‘Capacity’(toDateKey)  >  ‘arrivals(DateKey),

‘Capacity’(fromTimeKey)  <  ‘arrivals(TimeKey),

‘Capacity’(toTimeKey)  <  ‘arrivals(TimeKey) ),

Best Regards,
Angelia

Greg_Deckler
Super User
Super User

Have a look at my Open Tickets and Periodic Billing Quick Measures in the Quick Measure Gallery. They deal with time ranges.

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks, I'l give it a look and let you know if it does the trick.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors