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

How to count the number of times a value appears in a table and then sum it

I have a number of columns in a table as below

 

UPRNOutcome
789Justified
123Justified
456Justified
123Justified
123Not justified
456Not justified
123Justified

 

What I would like to do is count the number of times a UPRN appears in the table, where the outcome code is "Justified".

So in the table above what I would end up with is an additional column / measure like below:

 

UPRNOutcomeCount of justified for UPRN
789Justified1
123Justified3
456Justified1
123Justified3
123Not justified3
456Not justified1
123Justified3

 

I would then need something to tell me how many unique UPRN's are recorded against the Count of Justified for UPRN column ultimately ending up with the table below:

 

Count of justified for UPRNUnique UPRN's that match
12
20
31
40

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Rob_Morris ,

 

The pbix file is here.

9.png

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Rob_Morris ,

 

The pbix file is here.

9.png

 

Best Regards,

Stephen Tao

 

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

Thank you for this.

Very helpful and did exactly what I wanted.

Anonymous
Not applicable

@Rob_Morris  you can use the below measure for count of justified & Non justified

countof j = calculate(countrows('Table'),'Table'[Outcome]="Justified" || 'Table'[Outcome]="Not Justified")

distnctof j = calculate(countrows(values('Table'[UPRN])),'Table'[Outcome]="Justified" || 'Table'[Outcome]="Not Justified")

Appreciate your Kudos, Press the thumbs up button!!👍


Regards,
Husna



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.