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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
apagan
Helper I
Helper I

Count rows in a Table that have a specific value

I am using the formula below in an attempt to count the number of rows in a table that contain a value of "Pass" in a specific column, but this appears to be giving me a count of all the rows in the table - reguardless of the value the column contains.  What am I doing wrong?

 

Pass= COUNTAX(Samples,Samples[AnalysisResult]="Pass")

 

Thanks, in advance!

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@apagan

 

try with this:

 

Pass= COUNTROWS(filter(Samples,Samples[AnalysisResult]="Pass"))




Lima - Peru

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Measure = CALCULATE(COUNTAX(Samples,Samples[AnalysisResults]),Samples[AnalysisResults]="Pass")


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Great stuff, but a quick question.  Instead of using "Pass" (which is as string), what do I do If I want to use a column value?  Here's what I'm trying to do:

 

Table 1 has repetitive text values in one column, I created Table 2, with the simple formula "DISTINCT ('Table 1' [Column 1])": this gave me all unique values of Table 1/column 1 onto Table 2/Column 1.  

 

Table 2

Col 1 (unique)

Jon

Victor

Taha

Jessica

Kate

 

Now, I'm trying to add column 2 to Table 2, and in this column 2, I want the values to count how many times did each name occur in Table 1.

 

Thanks for your help

Vvelarde
Community Champion
Community Champion

@tahmed

 

with this solve your question:

 

Column2 = COUNTROWS(RELATEDTABLE(Table1))




Lima - Peru

WOW!! That was very smart & fast, thanks so much for your help.  One last thing, so now if I want to go one step further & create a new table 3 with the unique frequencies.  Example:

 

Table 2:

Column 1                                   Column 2 = COUNTROWS(RELATEDTABLE(Table1))

Jon                                              5

Victor                                          1

Taha                                            1

Jessica                                         9

Kate                                             1

 

Table 3:

Column 1 (Unique)                    Column2

1                                                 3

5                                                 1

9                                                 1

 

 

Any idea how I can do this, thanks again for your quick response & help.  

 

Vvelarde
Community Champion
Community Champion

@apagan

 

try with this:

 

Pass= COUNTROWS(filter(Samples,Samples[AnalysisResult]="Pass"))




Lima - Peru

Outstanding!  Thank you!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.