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
aloosh89
Helper I
Helper I

Counting occurence of a specific attribute value for each ID

Hello,

 

I would like to count the occurence of the value of attribute1 = 'A', for each unique ID. Please see below:

 

 

 

IDAttribute 1Attribute 2
1AY
1AZ
1BW
2BW
2CW
3AW

 

Essentially, the output I am looking for is a measure that counts these occurences of 'A'. So for ID=1, the measure should equal 2. For ID=2, the measure should equal 0. For ID=3, the measure should equal 1.

 

Thanks in advance.

Ali 

1 ACCEPTED SOLUTION
nandukrishnavs
Super User
Super User

@aloosh89 Try this

 

Measure =
COUNTX (
    FILTER (
        'Table',
        'Table'[Attribute 1] = "A"
    ),
    'Table'[ID]
) + 0

 

Or 

Measure =
CALCULATE (
    COUNT ( 'Table'[ID] ),
    'Table'[Attribute 1] = "A"
) + 0

nandukrishnavs_0-1691404621029.png

 


Regards,
Nandu Krishna

View solution in original post

2 REPLIES 2
aloosh89
Helper I
Helper I

@nandukrishnavs  thanks for your help. this works. 

nandukrishnavs
Super User
Super User

@aloosh89 Try this

 

Measure =
COUNTX (
    FILTER (
        'Table',
        'Table'[Attribute 1] = "A"
    ),
    'Table'[ID]
) + 0

 

Or 

Measure =
CALCULATE (
    COUNT ( 'Table'[ID] ),
    'Table'[Attribute 1] = "A"
) + 0

nandukrishnavs_0-1691404621029.png

 


Regards,
Nandu Krishna

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.