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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.