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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DarrelDonatto
Frequent Visitor

Help Counting Number of Records Filtered in Two Separate Tables

I need to count the number of times that both a column in one table has a certain value and a column in another table has a certain value.

 

I have a Filter for the 'epro trauma data' table: 

CALCULATE(COUNTROWS('epro trauma data'), FILTER('epro trauma data', 'epro trauma data'[TIME_OF_TRAUMA_ALERT]<>""))
 

I have a filter for the 'cad inmain' table: 

CALCULATE(COUNTROWS('cad inmain'), FILTER('cad inmain','cad inmain'[secsar2tr]<900))

 

What I need is to count the rows in 'epro trauma data' when both conditions exist.

 

'epro trauma data' is linked to 'epro incident data' by a one-to-one relationship with filtering in both directions.

'epro incident data' is linked to 'cad inmain' by a many-to-one relationship with filtering in both directions.


Tables.JPG

 

Any help would be appreciated.

 

Once this is all done - I need to be able to use slicers for date and a few other fields in "'epro incident data'

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

Hi @DarrelDonatto ,

According to your description, here's my solution.

Count is a measure in epro trauma data table.

Count = 
CALCULATE (
    COUNTROWS ( 'epro trauma data' ),
    FILTER (
        ALL ( 'epro trauma data' ),
        'epro trauma data'[TIME_OF_TRAUMA_ALERT] <> BLANK ()
    ),
    FILTER ( ALL ( 'cad inmain' ), 'cad inmain'[secsar2tr] < 900 )
)

 Get the expected result.

vkalyjmsft_0-1640068485341.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @DarrelDonatto ,

According to your description, here's my solution.

Count is a measure in epro trauma data table.

Count = 
CALCULATE (
    COUNTROWS ( 'epro trauma data' ),
    FILTER (
        ALL ( 'epro trauma data' ),
        'epro trauma data'[TIME_OF_TRAUMA_ALERT] <> BLANK ()
    ),
    FILTER ( ALL ( 'cad inmain' ), 'cad inmain'[secsar2tr] < 900 )
)

 Get the expected result.

vkalyjmsft_0-1640068485341.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much.  Works perfectly..

DarrelDonatto_0-1640095970674.png

 

lbendlin
Super User
Super User

You can combine these filters

 

 

CALCULATE(COUNTROWS('epro trauma data'), 'epro trauma data'[TIME_OF_TRAUMA_ALERT]<>"",'cad inmain'[secsar2tr]<900)

 

 

However your data model may not support this query.

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!

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