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
haefnja
Frequent Visitor

Calculated Column with filters across tables

I am trying to create a new calculated column across two of my current tables.  Table 1 has the fields of "MachineID", "Start Time" and "End Time".  The start and end times here are usually 12 hours apart and they are representing the entire shift structure.

Table 2 has some material usage information, which has a similar "MachineID" column, as well as start and stop times at more frequent intervals, usually 15 minutes, and a total material usage column.

What I am trying to do is do a calculated column that sums the 15-minute intervals on Table 2 when the MachineID matches and the timeframes in Table 2 are between the start and stop times of my total shift in Table 1.

Times are in Date/Time format in both tables

I tried to do this calculed column in Table 1:

TotalMtlUsage = CALCULATE(sum(Table2[Totals]), Table2[MachineID]=Table1[MachineID], Table2[StartTime]>=Table1[StartTime], Table2[EndTime]<=Table1[EndTime])

but it is giving me errors saying "The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression".

Can anyone give me some suggestions or a better way to do this?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@haefnja , Try a new column like

 

TotalMtlUsage = CALCULATE(sum(Table2[Totals]),filter(Table2, Table2[MachineID]=Table1[MachineID] && Table2[StartTime]>=Table1[StartTime] && Table2[EndTime]<=Table1[EndTime]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
haefnja
Frequent Visitor

@amitchandak Thanks a bunch, that works! Figured it would be a simple fix.

amitchandak
Super User
Super User

@haefnja , Try a new column like

 

TotalMtlUsage = CALCULATE(sum(Table2[Totals]),filter(Table2, Table2[MachineID]=Table1[MachineID] && Table2[StartTime]>=Table1[StartTime] && Table2[EndTime]<=Table1[EndTime]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.