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
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
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.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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