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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors