Forum Discussion

apagan's avatar
apagan
Helper I
9 years ago
Solved

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!

6 Replies

  • Vvelarde's avatar
    Vvelarde
    Community Champion

    apagan

     

    try with this:

     

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

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    Measure = CALCULATE(COUNTAX(Samples,Samples[AnalysisResults]),Samples[AnalysisResults]="Pass")
    • tahmed's avatar
      tahmed
      Advocate II

      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's avatar
        Vvelarde
        Community Champion

        tahmed

         

        with this solve your question:

         

        Column2 = COUNTROWS(RELATEDTABLE(Table1))