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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
pigip
Frequent Visitor

Count the number of row based on condition

Hello, PowerBI Guru

 

Based on raw data, I made one matrix which can tell the pass ratio for each component. The drill up to year and drill down to month can be supported. I would like to count the component which has test run and also which pass ratio > 95% for YEAR, or YEAR MONTH depends on drill up/down.  For example, on 2020/01, 3 components have test run, and PassRatio of 2 > 95%, on 2020/02, 2 components tested and 1 component’s PassRatio > 95%. How can I create the measure ? The pbix is attached.  Thanks in Advanced !

matrix.png

Here is raw data.  Here is pbix link

Item ID

Component

Test Date

Pass/Fail

P0001

A

20/01/2020

Pass

P0002

A

20/01/2020

Pass

P0003

B

20/01/2020

Pass

P0004

C

20/01/2020

Fail

P0005

B

20/01/2020

Pass

P0006

A

25/01/2020

Pass

P0007

B

25/01/2020

Pass

P0008

C

25/01/2020

Pass

P0009

B

25/01/2020

Pass

P0010

C

25/01/2020

Pass

P0011

C

25/01/2020

Fail

P0012

A

25/01/2020

Pass

P0013

B

15/02/2020

Pass

P0014

B

15/02/2020

Pass

P0015

B

15/02/2020

Pass

P0016

B

15/02/2020

Pass

P0017

A

15/02/2020

Pass

P0018

B

20/02/2020

Pass

P0019

A

20/02/2020

Fail

P0020

B

17/03/2020

Pass

P0021

B

17/03/2020

Pass

P0022

B

17/03/2020

Pass

P0023

B

17/03/2020

Pass

P0024

B

17/03/2020

Pass

P0025

B

17/03/2020

Pass

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@pigip - I think % would be something like:

Count =
  VAR __Table = 
    ADDCOLUMNS(
      ADDCOLUMNS(
        SELECTCOLUMNS(SUMMARIZE('Table',[Component]),"Comp",[Component])
        "Pass",COUNTROWS('Table','Table'[Component] = [Comp] && 'Table'[Pass/Fail]="Pass"),
        "Fail",COUNTROWS('Table','Table'[Component] = [Comp] && 'Table'[Pass/Fail]="Fail")
      ),
      "Percent",[Pass] / ([Pass] + [Fail])
    )
RETURN
  COUNTROWS(FILTER(__Table,[Percent] >= .95)) 


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@pigip - I think % would be something like:

Count =
  VAR __Table = 
    ADDCOLUMNS(
      ADDCOLUMNS(
        SELECTCOLUMNS(SUMMARIZE('Table',[Component]),"Comp",[Component])
        "Pass",COUNTROWS('Table','Table'[Component] = [Comp] && 'Table'[Pass/Fail]="Pass"),
        "Fail",COUNTROWS('Table','Table'[Component] = [Comp] && 'Table'[Pass/Fail]="Fail")
      ),
      "Percent",[Pass] / ([Pass] + [Fail])
    )
RETURN
  COUNTROWS(FILTER(__Table,[Percent] >= .95)) 


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@pigip , Not very clear, This will give Ratio

divide(calculate(countrows(Table), filter(Table, Table[Pass/Fail] ="Pass")) ,calculate(countrows(Table)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors