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
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")

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

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

 
Greg_Deckler
Super User
Super User

@RA_gov - 

 

Place Bank name and this measure in a visual:

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

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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