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
bdmichael09
Helper II
Helper II

Count of a count in a measure

Hello PBI community,

 

I'm trying to accomplish something that I've been struggling to get to work for a number of hours now and reading other threads has not inspired me to a measure that works.

 

I have a table of active borrowers (Portfolio). I have a table of new applications (Leads). My end goal is slightly more complicated but what I am trying to produce is simply a card that shows 'count of active borrowers with new leads' and a card of "count of borrowers without new leads".

 

The portfolio table has a ServicedLoanNumber, start date, and end date fields. The Leads table has the new application number (LoanNumber), the lead date and the ServicedLoanNumber fields. The two tables have a relationship on the ServicedLoanNumber. I understand that I could use a calculated column to get the count of occurences in the Leads table but for what I'm working towards in the end, the column will not work.

 

I thought I could do something like

CALCULATE( COUNT( Portfolio[ServicedLoanNumber] ), COUNTROWS( Portfolio[ServicedLoanNumber] ) = 0 )

to be a measure of "count of borrowers without new leads" but PBI doens't seem to like that much. I've tried some other things too but I haven't exactly been saving each failed method in separate measures so it's hard to say what exactly I've tried.

 

Any help is appreciated. 

Just as an example of what I expect, with this made up sample below, I would expect to get 3 as an output of "count of active borrowers with new leads" and 2 as an output of "ount of active borrowers without new leads"

ServicedLoanNumberJoinDateLeaveDate
11/1/20226/1/2022
21/1/2021 
31/1/2020 
41/1/2020 
51/1/2020 

 

LoanNumberServicedLoanNumberCreateDate
10014/1/2022
10114/30/2022
10215/15/2022
10322/1/2022
10433/1/2022
10534/1/2022
10625/1/2022
10721/1/2022
10823/15/2022
10924/15/2022
1 ACCEPTED SOLUTION
v-mengzhu-msft
Community Support
Community Support

Hi @bdmichael09 ,

 

Please try the following measure:

Count of active borrowers with new leads = COUNTROWS(INTERSECT(SELECTCOLUMNS('Portfolio',"pro",'Portfolio'[ServicedLoanNumber]),SELECTCOLUMNS('Leads',"Lea",'Leads'[ServicedLoanNumber])))
count of active borrowers without new leads = COUNTROWS(EXCEPT(SELECTCOLUMNS('Portfolio',"por",'Portfolio'[ServicedLoanNumber]),SELECTCOLUMNS('Leads',"Lea",'Leads'[ServicedLoanNumber])))

Then you can get effect you want to achieve, as the image shows:

vmengzhumsft_0-1656993273590.png

 

 

Best regards,

Community Support Team Selina zhu

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-mengzhu-msft
Community Support
Community Support

Hi @bdmichael09 ,

 

Please try the following measure:

Count of active borrowers with new leads = COUNTROWS(INTERSECT(SELECTCOLUMNS('Portfolio',"pro",'Portfolio'[ServicedLoanNumber]),SELECTCOLUMNS('Leads',"Lea",'Leads'[ServicedLoanNumber])))
count of active borrowers without new leads = COUNTROWS(EXCEPT(SELECTCOLUMNS('Portfolio',"por",'Portfolio'[ServicedLoanNumber]),SELECTCOLUMNS('Leads',"Lea",'Leads'[ServicedLoanNumber])))

Then you can get effect you want to achieve, as the image shows:

vmengzhumsft_0-1656993273590.png

 

 

Best regards,

Community Support Team Selina zhu

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

Jos_Woolley
Solution Sage
Solution Sage

Hi,

So each ServicedLoanNumber only appears once in the Portfolio table?

If so, for count of active borrowers without new leads you could try:

 

Count of active borrowers without new leads =
COUNTROWS(
    EXCEPT(
        SELECTCOLUMNS( Portfolio, "LoanNo", Portfolio[ServicedLoanNumber] ),
        SELECTCOLUMNS( Leads, "LoanNo", Leads[ServicedLoanNumber] )
    )
)

 

You could then simply subtract that from the total number of rows in the Portfolio table to obtain your other metric.

Regards

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.

Top Solution Authors