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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Txtcher
Helper V
Helper V

Most Efficient Way to Count with Filters from Another Table

I have 2 tables:  HCR Intakes  & Allegations. The are related to each other with a 1-many relationship using a field called Intake Id (HCR Intakes have many Allegations).

I am trying to obtain a count of the allegations for each Intake in HCR Intakes.

This is the measure I created and it is working, but I am still new to DAX and am wondering if this is an efficient way:

Allegation Count = 
VAR xFilterAllegations = FILTER(Allegations,Allegations[Intake Id] = RELATED('HCR Intakes'[Intake Id]))
RETURN
CALCULATE(
    COUNTROWS(RELATEDTABLE('HCR Intakes')),
    xFilterAllegations)

 

Here are some sample tables:

HCR Intakes:

Intake IdDate Recieved
11/1/2025
21/20/2025
33/5/2025
44/25/2025

Allegations

Allegation NoIntake Id
A11
A21
A32
A42
A55
A66
A77

 

Expected outcome for Count of Allegations is:  4  (Intake Id 1 & 2 match HCR Intake [Intake id])

 

2 ACCEPTED SOLUTIONS
FBergamaschi
Super User
Super User

Hi,

I would reduce te measure to only

Allegation Count NEW =
 CALCULATE(
    COUNTROWS( Allegations ),
    'HCR Intakes'
 )
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

View solution in original post

techies
Super User
Super User

Hi @Txtcher please try this

 

Allegation =
CALCULATE(
    COUNTROWS(Allegations),
    TREATAS(VALUES('HCR Intakes'[Intake Id]), Allegations[Intake Id])
)
 
 
Power BI & Microsoft Fabric
PL-300 | DP-600 | DP-700 Certified

View solution in original post

3 REPLIES 3
Txtcher
Helper V
Helper V

Thank you @FBergamaschi  & @techies .  Both solutions work. 😁

And, the measure I created was not working because it was counting intakes, not allegations. Doh! 
Good grief.  

techies
Super User
Super User

Hi @Txtcher please try this

 

Allegation =
CALCULATE(
    COUNTROWS(Allegations),
    TREATAS(VALUES('HCR Intakes'[Intake Id]), Allegations[Intake Id])
)
 
 
Power BI & Microsoft Fabric
PL-300 | DP-600 | DP-700 Certified
FBergamaschi
Super User
Super User

Hi,

I would reduce te measure to only

Allegation Count NEW =
 CALCULATE(
    COUNTROWS( Allegations ),
    'HCR Intakes'
 )
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.