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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
carrollag
New Member

COUNTIF IN DAX with filters

I am new to PowerBI and am trying to figure out how to convert the below formula into DAX. This formula is being used to filter and pull a total count from multiple columns located within one very large report.  

 

=SUM(COUNTIFS('REG Major Reports Combined'!G:G, "Y", 'REG Major Reports Combined'!H:H, "MAT", 'REG Major Reports Combined'!I:I, "MEC"), COUNTIFS('REG Major Reports Combined'!G:G, "Y", 'REG Major Reports Combined'!Q:Q, "MAT", 'REG Major Reports Combined'!R:R, "MEC"))

 

Thanks! 

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

Hi, @carrollag ;

You could create a measure as follows:

count =
COUNTROWS (
    FILTER ( 'REG Major Reports Combined', [G] = "Y" && [H] = "MAT" && [I] = "MEC" )
)
    + COUNTROWS (
        FILTER ( 'REG Major Reports Combined', [G] = "Y" && [Q] = "MAT" && [R] = "MEC" )
    )

Best Regards,
Community Support Team_ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi, @carrollag ;

You could create a measure as follows:

count =
COUNTROWS (
    FILTER ( 'REG Major Reports Combined', [G] = "Y" && [H] = "MAT" && [I] = "MEC" )
)
    + COUNTROWS (
        FILTER ( 'REG Major Reports Combined', [G] = "Y" && [Q] = "MAT" && [R] = "MEC" )
    )

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ValtteriN
Super User
Super User

Hi,

So you want a sum of countifs? Here is one way to achieve this:

Example data:

ValtteriN_0-1643220519498.png


Dax:

Countifs = COUNTROWS(FILTER('Matrix example','Matrix example'[Material]="Wood"&&'Matrix example'[Item]="Item1"))
So here we count the rows where material is Wood and item is Item1


End result:
ValtteriN_1-1643220591086.png


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@carrollag , You can have measure like

countrows(filter('REG Major Reports Combined'[G] = "Y" && 'REG Major Reports Combined'[H] = "MAT" && 'REG Major Reports Combined'[I] = "MAT" ))

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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