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
Anonymous
Not applicable

Count occurrence in a column that doesnt happen in another

Hello there,

 

I'd like to count how many times a value is shown in the Partner column as long as it doesn't appear in the Customer column. I've tried using something akin to that, but has not worked:

CALCULATE(COUNTROWS('Base name'), 'Base name'[Partner] <> 'Base name'[Customer])

 

Perhaps the reason on why this measure has not worked is the relationship between tables, however even using USERELATIONSHIP('Dimension table'[Name of the client], 'Fact table'[Partner]) I got nothing. In the example of the image, the table is a Fact type table, and its active relationship is between the Customer and another column from a dimension table.

 

Any thoughts on where I'm doing wrong?

 

pedrohp503_1-1651559595886.png

 

P.S.: In this table, my customer can be a partner as well.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You should use a partner from the dimension. this should work

 

CALCULATE(COUNTROWS('Base name'),filter( 'Base name',  'Base name'[Partner] <> 'Base name'[Customer]) )

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

View solution in original post

4 REPLIES 4
philouduv
Resolver III
Resolver III

Hey @Anonymous ,

In your Dimension 'Dimension table'[Name of the client] write : 

test = CALCULATE(COUNTROWS('Base name'),
Filter(ALL('Base name'),
'Dimension table'[Name of the client] == 'Base name'[Patner]
&&
'Base name'[Patner] <> 'Base name'[Customer]))


Best regards,

 

Anonymous
Not applicable

Thanks, my friend

amitchandak
Super User
Super User

@Anonymous , You should use a partner from the dimension. this should work

 

CALCULATE(COUNTROWS('Base name'),filter( 'Base name',  'Base name'[Partner] <> 'Base name'[Customer]) )

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

Thank you. It indeed worked 🤙

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.