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

Comparing multiple columns between multiple tables

I have a table (table 1) with data for assets in specific geographic areas with an 'entry time', 'exit time' and 'region id'.

 

I have another table (table 2) which contains data for certain incidents in those same areas. This table has a 'date of incident' and the same (related) 'region id'.

 

I want to add a column to table one that is the result of the following rules:

- region id is the same
- entry time is before date of incident
- exit time is after date of incident

 

Is anyone able to help me out with this?

 

EDIT: I'm looking to return a boolean value, or more preferably (not sure if this is possible) a count of all the incidents that happened between the entry time and exit time, providing the region id matches.

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

Hi, @owenv 

 

If you can share some sample data, we can provide more specific code.

According to your description, you can try:

COUNTROWS (
    FILTER (
        Table2,
        table2[region id] = table1[region id]
            && table2[date of incident] >= Table1[entry time]
            && table2[date of incident] <= Table1[exit time]
    )
)

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @owenv 

 

If you can share some sample data, we can provide more specific code.

According to your description, you can try:

COUNTROWS (
    FILTER (
        Table2,
        table2[region id] = table1[region id]
            && table2[date of incident] >= Table1[entry time]
            && table2[date of incident] <= Table1[exit time]
    )
)

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

amitchandak
Super User
Super User

@owenv , Not sure which column you want from table 2

 

Try a new column like

 

maxx(filter(Table2, table2[region id] = table2[region id] && table2[date of incident] <= Table1[exit time] && table2[date of incident] <= Table1[exit time]), Table2[Column])

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

This is close. Apologies, I should have been clearer. I'm looking to return a boolean value

 

@amitchandak I've just edited my post above but thought I'd add it here. Not sure how these forums work yet and if you get notified of an edit to the original post. I thought after I posted this reply that more preferably (not sure if this is possible) I'd like to return a count of all the incidents that happened between the entry time and exit time, providing the region id matches.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.