cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Multiple Filters (COUNTROWS)

Hi,

 

I am struggling to get a result for COUNTROWS based on multiple critera.

From the table I am trying to filter all Males with a grade of either C,D or E and to give me the count of rows. 

 

This is what I have:

CALCULATE(COUNTROWS(Tbl_ORG001),Tbl_ORG001[HCD_Gender] = "M",Tbl_ORG001[HCD_Band] = "C",Tbl_ORG001[HCD_Band] = "D",Tbl_ORG001[HCD_Band] = "E")

 

This does not come back with an error, but just displays nothing in the column.

 

Can anyone help?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Re: Multiple Filters (COUNTROWS)

MaleCDEcount = CALCULATE(
                                                 COUNTROWS(Grades),
                                                    FILTER(Grades,Grades[Gender]="M"),
                                                    FILTER(Grades,
                                                         Grades[Grade]="c" || Grades[Grade]="d" || Grades[Grade]="e")

                                                )

 

My table is named 'Grades' - you will want to change this code to your table name.

 

www.CahabaData.com

View solution in original post

2 REPLIES 2
Highlighted
Memorable Member
Memorable Member

Re: Multiple Filters (COUNTROWS)

MaleCDEcount = CALCULATE(
                                                 COUNTROWS(Grades),
                                                    FILTER(Grades,Grades[Gender]="M"),
                                                    FILTER(Grades,
                                                         Grades[Grade]="c" || Grades[Grade]="d" || Grades[Grade]="e")

                                                )

 

My table is named 'Grades' - you will want to change this code to your table name.

 

www.CahabaData.com

View solution in original post

Highlighted
Continued Contributor
Continued Contributor

Re: Multiple Filters (COUNTROWS)

@RichWyeth

 

Another potential implementation could be:

 

CALCULATE(
    COUNTA(Tbl_ORG001), Tbl_ORG001[HCD_Gender] = "M",
        OR(Tbl_ORG001[HCD_Band] = "C",
            OR(Tbl_ORG001[HCD_Band] = "D", Tbl_ORG001[HCD_Band] = "E",)
)
)

This applies a filter of Male and considers all rows that have a grade of either C, D or E and returns a count of rows that satisfy that filter.

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors