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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
aflintdepm
Helper III
Helper III

Count Rows with Relationship Filter

I have 2 tables connected by a 1 to Many relationship for "Reason"

aflintdepm_0-1670021389141.png

The Classification Table looks like this:

aflintdepm_1-1670021427274.png

 

I'm trying to create a measures that allows me to count the Reason column in the NTUC Report table, filtered by the Classification column in the Classification table.

 

So, the desired result would be

Count the rows in 'NTUC Report' where the 'Reason' is Classification: NTUC

Count the rows in 'NTUC Report' where the 'Reason' is Classification: Ops Non-Admit

Count the rows in 'NTUC Report' where the 'Reason' is Classification: Not Classified

 

I cannot figure out how to use the relationship as the filter.  My only other thought is to enter a really long conditional formula in a helper column.

 

All help is appreciated

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @aflintdepm 

 

You can try the following methods.

Sample data:

vzhangti_0-1670221509540.png

vzhangti_2-1670221622852.png

Measure =
CALCULATE (
    COUNT ( 'NTUC Report'[Reason] ),
    FILTER (
        ALL ( 'Classification' ),
        [Classification] = SELECTEDVALUE ( Classification[Classification] )
    )
)

vzhangti_1-1670221566992.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @aflintdepm 

 

You can try the following methods.

Sample data:

vzhangti_0-1670221509540.png

vzhangti_2-1670221622852.png

Measure =
CALCULATE (
    COUNT ( 'NTUC Report'[Reason] ),
    FILTER (
        ALL ( 'Classification' ),
        [Classification] = SELECTEDVALUE ( Classification[Classification] )
    )
)

vzhangti_1-1670221566992.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

rohit_singh
Solution Sage
Solution Sage

Hi @aflintdepm ,

Since you have a relationship between the two tables, you could try these approaches :

Approach 1
1) On the 'NTUC Report' table, create a new column called 'Classification' as 
Classification = RELATED(Classfication[Classfication])

Using the related function, you can add the classification column directly to your 'NTUC Report' table and hence everything you need to create your measure is now on the same table.

2) Create mesaures such as 

Classification_NTUC = 
COUNTROWS(
                 FILTER('NTUC Report', 'NTUC Report'[Classfication] = "NTUC")
)

and so on 

Approach 2

Directly use the COUNTROWS and RELATEDTABLE functions as explained in Example2 here :
COUNTROWS function (DAX) - DAX | Microsoft Learn

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors