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
Anonymous
Not applicable

Computing Percentage Test Results (String) for a Certain Application (Category)

Hello,

 

I am looking to create a Table where I have mulitple different web apps that I support that contains a column that shows the results of a security scan as a string value of Pass or Fail. These tests run multiple times a month many times for the same app in one month, so my data may look like this: 

 

Application NameDate PerformedTest Results
Database App1/16/2021Pass
Apple App1/17/2021

Fail

Database App1/18/2021

Pass

Apple App2/20/2021

Pass

CRM App2/25/2021

Fail

 

In PowerBi, I am trying to find the pass rate (%) of each of the apps.

 

So I want to calculate for each distinct app: COUNT(Pass) / (COUNT("Pass")+Count("Fail")) to give me a percentage. 

 

What I did was create 2 calulated columns:

1.  Pass Column - 

 

 

IF(Table1[Test Result]="Pass",1,0)

 

 

-- If Test Result = pass, then put 1 in column, else 0

 

2. Pass Rate Calculation - 

 

 

SUM(Table1[Pass Column])/(COUNT(Table1[Pass Column]))

 

 

Explained: Sum of total passes divided by the count of tests (total tests)

The part that I am stuck on is that I need this calculation to calculate the percentage based on the Application Name. 

 

Is there a way to specify the Application Name (Category) for the calculation? 

 

I need my results to look like this:

Application NamePass Rate (%)
Database App85%
CRM App

91%

Apple App

75%

 

I apologize if this is confusing, I'm just starting to learn PowerBi.


8 REPLIES 8
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

Is your problem solevd? If not, pls let me know.

From your original description, I found that your needs are very simple, but your description and practices are confusing. How are these results calculated? We only need to know your complete calculation logic(pure text description). 

vjaneygmsft_1-1634114031438.png

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.


Best Regards,

Community Support Team _ Janey

parry2k
Super User
Super User

@Anonymous I'm referring to sample data you posted in your original post, it is 3/5, no? But you are not replying to what % you are expecting based on your original sample data?

 

Application Name Date Performed Test Results
Database App 1/16/2021 Pass
Apple App 1/17/2021

Fail

Database App 1/18/2021

Pass

Apple App 2/20/2021

Pass

CRM App 2/25/2021

Fail



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous not sure based on the sample data how you are getting 66%, the way you are calculating it should 3/5 = 60% ( sum of 3 pass rows and total rows = 5 ) how you are showing 2/3?

 

Also based on your data, how you expected your final test results to be the % you are showing? You have to be very clear about what you are looking for specifically when you are showing sample data the make sure your expected output is based on the sample data.

 

Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thank you for the resource link. 

 

I am getting 66% from my example reply to you. In that example, this would be the percentage for 1 application category

 Pass/Fail1 if Pass, 0 if fail
 Pass1
 Fail0
 Pass1

 

So in this example, I would have 2 passes and 3 total rows. So the calculation would be 2/3 (66%)

AlexisOlson
Super User
Super User

If you create a table or matrix visual and you put Application Name and your Pass Rate measure in it, what are you currently getting?

Anonymous
Not applicable

I'm getting very high percentages, something like 1600% for one of the values, all over 100%

parry2k
Super User
Super User

@Anonymous you are complicating the calculations, how you are getting to that % you are looking for.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

In the first column, I am turning the String Value Pass into a number (1) and if the string value does not equal Pass, I am putting 0 in the row value. 

 

Then I am taking a SUM of the column, so it is adding up all the 1's. 

Then I am dividing that sum by the count of total rows in the column:

Pass/Fail1 if Pass, 0 if fail
Pass1
Fail0
Pass1

 

So in this example, I would have 2 passes and 3 total rows. So the calculation would be 2/3 (66%)

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.