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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RA_gov
Frequent Visitor

From a big list with duplicates, isolating records with certain criteria and counting

From TABLE1 containing all banks and their custodians, I need a DAX query(s) that isolates only BANK_NAME where CUSTODIAN_NAME = 'CUSTODIAN' ... and from that listing, shows me counts for all their other custodians.

 

Restults would look like:

COLORADO BANK    1

MIDWAY BANK           3

UNION BANK                0

 

Thanks for the help!

RA

 

TABLE1

BANK_NAMECUSTODIAN_NAME
UNION BANKBUSINESS A
COMMUNITY BANKBUSINESS BB
COLORADO BANKCUSTODIAN
COLORADO BANKBUSINESS A
STANDARD BANKBUSINESS CCC
STANDARD BANKBUSINESS BB
DOVETAIL S&LBUSINESS A
MIDWAY BANKBUSINESS BB
MIDWAY BANKBUSINESS A
MIDWAY BANKBUSINESS CCC
MIDWAY BANKCUSTODIAN
UNION BANKCUSTODIAN
HAWAII BANKBUSINESS CCC
FIRST BANKBUSINESS CCC

 

 

 

11 REPLIES 11
amitchandak
Super User
Super User

@RA_gov , Try a measure like

calculate(distinctcount(Table[CUSTODIAN_NAME]),Table[CUSTODIAN_NAME] <>"CUSTODIAN")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Nope. 

 

I Need:         If  BANK_NAME has CUSTODIAN_NAME = 'CUSTODIAN', count all the other custodians for that particular bank

Anonymous
Not applicable

@RA_gov 

 

This should work

Measure 2 =
VAR Custodians =
    COUNTROWS ( FILTER ( 'Table (2)', 'Table (2)'[CUSTODIAN_NAME] = "CUSTODIAN" ) )
RETURN
    IF (
        Custodians >= 1,
        COUNTROWS ( FILTER ( 'Table (2)', 'Table (2)'[CUSTODIAN_NAME] <> "CUSTODIAN" ) ),
        0
    )

Not there yet. 

BANK_NAME has to be the result of the VAR phrase, then BANK_NAME VAR joined against the remaining list to pull out those where <>= CUSTODIAN 

 

I'm too new to DAX to figure this out.  I appreciate your help.

Hi @RA_gov ,

 

 

The above code will work, if you remove the 0 from the If statement.

 

Also, your output for Union Bank should be 1 and not 0.

 

YOu can try this measure too, but maynot be the best solution.

 

Measure 2 = 

var __TableC =

CALCULATETABLE(VALUES('Table (2)'[BANK_NAME]), 'Table (2)'[CUSTODIAN_NAME] = "CUSTODIAN" )

var __TableNC = 
CALCULATETABLE(VALUES('Table (2)'[BANK_NAME]), 'Table (2)'[CUSTODIAN_NAME] <> "CUSTODIAN" )

RETURN

COUNTX(FILTER('Table (2)' ,'Table (2)'[BANK_NAME] IN INTERSECT(__TableNC,__TableC) && 'Table (2)'[CUSTODIAN_NAME] <> "CUSTODIAN"),'Table (2)'[CUSTODIAN_NAME])

 

 

1.jpg

 

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

this works!

Thanks.

 

I am having issues accepting and posting kudos.  system gives me an error when i attempt to give you kudos.  your solution wins.

Thanks 

RA_gov
Frequent Visitor

Thanks, but not the answer I need. 

 

Yours says:      If BANK has CUSTODIAN, count it

I Need:         If  BANK has CUSTODIAN, count all the other custodians for that particular bank

Anonymous
Not applicable

Hi @RA_gov Do as @Greg_Deckler suggest but  change the = sign to <>

 

But based on your description this should work. 

Measure 2 =
VAR Custodians =
    COUNTROWS ( FILTER ( 'Table (2)', 'Table (2)'[CUSTODIAN_NAME] = "CUSTODIAN" ) )
RETURN
    IF (
        Custodians >= 1,
        COUNTROWS ( FILTER ( 'Table (2)', 'Table (2)'[CUSTODIAN_NAME] <> "CUSTODIAN" ) ),
        0
    )

 

Appreciate with kudos.

Mark as solution if this resolves your problem.

 

 

 

Thanks

whoops


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

 
Greg_Deckler
Community Champion
Community Champion

@RA_gov - 

 

Place Bank name and this measure in a visual:

Measure =
  COUNTROWS(FILTER('Table',[CUSTODIAN_NAME] = 'CUSTODIAN'))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.