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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bflaviu
Regular Visitor

Filter COUNTROWS Where Values Equal Values from Another Table

I am tracking KPIs for some sales reps, so I have a table of all the sales calls they made witih a column that shows what sales method they used (Cold Calls, Meeting, Etc.)  Each sales rep has chosen a single type of method, and and goal number of calls for that method they must make a week, so in another table, I have the Sales Rep, the Method Type, and the Goal Number.  I want to create a measure, where I count only the sales calls from the Sales Calls table that match the chosen type for that sales rep as defined in the KPI table.

 

Tables.JPG

 

So I want to get a count from Sales Calls where if I chose the context of "John", it only counts the rows where the 'Sales Calls'[Method] = 'KPI Settings'[KPI Method] for John (so count all the "A" calls for Jonh, "A" calls for Bob, and "B" calls for Tim).

 

The tables are related by Sales Rep.

 

Thanks in advance! 

 

Flaviu

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

How about these 2 Measures?

 

Total Calls = COUNTROWS(SalesCalls)

KPI Method Calls =
CALCULATE (
    [Total Calls],
    FILTER (
        SalesCalls,
        SalesCalls[Method] = RELATED ( 'KPI Settings'[KPI Method] )
    )
)

EDIT: I used M1 (A) , M2 (B), M3 (C)

COUNTROWS - RELATED.png

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

How about these 2 Measures?

 

Total Calls = COUNTROWS(SalesCalls)

KPI Method Calls =
CALCULATE (
    [Total Calls],
    FILTER (
        SalesCalls,
        SalesCalls[Method] = RELATED ( 'KPI Settings'[KPI Method] )
    )
)

EDIT: I used M1 (A) , M2 (B), M3 (C)

COUNTROWS - RELATED.png

That worked perfectly!  Thanks!  I was really confused about how the RELATED function worked.  I was getting lost trying to use LOOKUPVALUE function.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.