Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Need to calculate Pass Rate and display it.. help! Post Reply Post New Topic
Author Message
tstaples
Newbie
Newbie


Joined: 09 Jun 2009
Location: United States
Online Status: Offline
Posts: 8
Quote tstaples Replybullet Topic: Need to calculate Pass Rate and display it.. help!
     Posted: 09 Jun 2009 at 8:14am
Hey everyone,

I'm very new to Crystal Reports and I have one last thing to do on my report that I cant figure out how.  I haven't learned how to use formulas yet so please excuse my ignorance...

I am using Crystal Reports 10 with IBM Rational ClearQuest.  I'm sending a data field to CR called "Result".  These are test cases and people fill in Pass/Fail/Blocked/Untested/NA.  So "Result" can be any of those.

Basically what i want to do is write a formula to calculate Pass Rate.
(Pass/(Pass+Fail))*100
and then display that somewhere in the report.
Probably very simple but i'm lost because the "Result" variable can contain 5 different values.

I'm assuming i'll need to do a count of some sort to find out how many Passes there are, how many Fails, etc.. etc...
then use those counts in my calculations.

I haven't the slightest clue how to do this.  No one in my company knows how to use Crystal Reports and they've thrown me at it because I can usually figure stuff out....

please help!!!!!
thanks in advance....

-Lost in CR land....


Edited by tstaples - 09 Jun 2009 at 8:30am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jun 2009 at 8:56am
There are few ways to do this but here is one where you can use 3 formulas.
I am going to assume you want this percentage for all records in the report. IF not you will need to alter this to use grouping. It also assumes you do not have duplicate data that needs to be ccounted for.
In your Field Explorer right click on Formula Fields and select New.
Name the first one "Pass"
The formula will be: if {table.Result_field}= "Pass" then 1 else 0
Repeat to create a second formula as 'Pass_Fail':
if {table.Result_field} in ["Pass","Fail"] then 1 else 0
Create a third formula for your percentage as "Percent Pass":
if SUM({@Pass_Fail})= 0 then 0 else
SUM({@Pass}) % SUM({@Pass_Fail}) 
Place this formula where you want it in the report
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Jun 2009 at 9:00am
You can probably use running totals, but I haven't, my solution is always shared variables.
 
if this calculation is for the whole report, we can skip the setting variables to 0.
 
you would create a couple of formulas.  First goes in detail section and would look like:
shared numbervar Pass;
shared numbervar PassFail;
 
if {table.field}="Pass" then Pass := Pass + 1;
if {table.field}="Pass" OR {table.field}="Fail" then PassFail := PassFail +1;
""  //hide the calculations.
 
in the group footer/report footer
shared numbervar Pass;
shared numbervar PassFail;
 
Pass/PassFail
 
HTH
IP IP Logged
tstaples
Newbie
Newbie


Joined: 09 Jun 2009
Location: United States
Online Status: Offline
Posts: 8
Quote tstaples Replybullet Posted: 09 Jun 2009 at 9:04am
OH MY GOD I LOVE YOU!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!

you don't even realize how happy you just made me!  You're a genius

:-)
IP IP Logged
tstaples
Newbie
Newbie


Joined: 09 Jun 2009
Location: United States
Online Status: Offline
Posts: 8
Quote tstaples Replybullet Posted: 09 Jun 2009 at 9:11am
Dblank,
I saw your post first so i implemented that.  But here's a problem.  I need to implement the grouping piece because I report on multiple test plans per report.  This means that I have to do a group, and calculate this pass rate for each unique test plan.

When i insert a group header #1 for ClearQuest.testplan_name
and then put @Percent Pass in the header what i'm seeing is it's taking all the passes and fails from all of the test plans to use in the calculation.  How do i make that formula only consider the group that it is currently in?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jun 2009 at 9:33am
You would create a group , change the third formula ('Percent Pass') to look at group level SUM data ... sum(field,groupedonfield)
 
 
Place this on the group footer or group header to view the % per group


Edited by DBlank - 09 Jun 2009 at 9:35am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum