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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sb14415
Frequent Visitor

Counting results with different criteria

I saw a similar post but I couldn't get the result to work for my data.

I have data that I simplified below. There are multiple serial #s and test results. Some tests pass the first time (#1,2,3,4). Some pass on a retest (#5,8). Some fail a restest (#6,12). Some fail and were not retested (#9,10,11). Some were tested and passed every time (#7). I would also like to get the results in the shown form which I'm sure is easy but I'm still learning

 

sb14415_0-1644948874865.png

 

 

 

Serial #Test result   
1pass   
2pass   
3pass   
4pass   
5fail   
5fail   
5pass   
6fail   
6fail   
7pass   
7pass   
8fail   
8pass   
9fail   
10fail   
11fail   
12fail   
12fail   
12fail   
12fail   
     
pass first timepass restestfail retestfail no retestpass multiple tests
42231
1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

You can create this kind of category measure to solve this issue:

Test Categories =

SWITCH(TRUE(),
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])))=1
&& MAX('Table (7)'[Test result])="pass",
"Pass first time",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>0 &&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))>0,
"Pass retest",


COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))=0&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))>0,
"Pass all",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>1&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))=0,
"Fail retest",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>0&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))=0,
"No retest")



Table (7) is just the test data.

Then create additional table like this:

ValtteriN_0-1644950939709.png

 

Create this kind of measure:

Test counts = sumx('Table (7)',if(MAX('test categories'[Value])=[Test Categories],1,0))



End result:

ValtteriN_1-1644950975269.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!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/






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

Proud to be a Super User!




View solution in original post

1 REPLY 1
ValtteriN
Super User
Super User

Hi,

You can create this kind of category measure to solve this issue:

Test Categories =

SWITCH(TRUE(),
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])))=1
&& MAX('Table (7)'[Test result])="pass",
"Pass first time",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>0 &&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))>0,
"Pass retest",


COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))=0&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))>0,
"Pass all",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>1&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))=0,
"Fail retest",

COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="fail"))>0&&
COUNTROWS(filter(all('Table (7)'),'Table (7)'[Serial #]=MAX('Table (7)'[Serial #])&&'Table (7)'[Test result]="pass"))=0,
"No retest")



Table (7) is just the test data.

Then create additional table like this:

ValtteriN_0-1644950939709.png

 

Create this kind of measure:

Test counts = sumx('Table (7)',if(MAX('test categories'[Value])=[Test Categories],1,0))



End result:

ValtteriN_1-1644950975269.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!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/






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

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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