Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Percent formula on condition 2

Status
Not open for further replies.

brookwood

Technical User
May 23, 2008
17
US
I'm new to CR XI, and I'm sure this is quite simple....but, here's my problem. I need to get the percent of Service Requests where the request type is a produciton correction. So here's what I've got so far...

count({V_BAR_SR.BAR_ID})%count({V_BAR_SR.BAR_TYPE})

I need the solution to WHERE V_BAR_SR.BAR_TYPE = "Production Correction" in my formula.

I will greatly appreciate any help. Also, would this formula be using what CR terms "shared variables"?

Thanks again!
 
If you don't have row inflation, you could use this formula:

//{@ProdCorr}:
if {V_BAR_SR.BAR_TYPE} = "Production Correction" then 1

Then use a formula like this for the percentage:

sum({@ProdCorr})%count({V_BAR_SR.BAR_ID})

...assuming bar_id is the id field for service requests. This would give the percentage at the report level. If you need it at a group level, you would have to insert a group condition for both values, as in:

sum({@ProdCorr},{table.groupfield})%count({V_BAR_SR.BAR_ID},{table.groupfield})

-LB
 
Try this:

if V_BAR_SR.BAR_TYPE = "Production Correction"
then (V_BAR_SR.BAR_TYPE/V_BAR_SR.BAR_ID) * 100

If you want to use this value more than once, yes, declare a variable as shared, then the statement. Like this:

shared numberVar prodCorr;
if V_BAR_SR.BAR_TYPE = "Production Correction"
then prodCorr := (V_BAR_SR.BAR_TYPE/V_BAR_SR.BAR_ID) * 100

Note the colon in the '=' sign. Use the := to return a value. Use = to return a boolean.

 
sorry - meant to use count.

shared numberVar prodCorr;
if V_BAR_SR.BAR_TYPE = "Production Correction"
then prodCorr := (count(V_BAR_SR.BAR_TYPE)/count(V_BAR_SR.BAR_ID)) * 100
 
lbass,

You are correct to assume that bar_id is the id field of the service request. And, I am trying to calculate percent at the group level. In this case, the group field is V_BAR_SR_ACTIVITY.ACTIVITY_CREATED_DATE. The value of course is a datetime value.

So, I'm afraid that I added a layer that I didn't describe before. The group evaluates on every month.

Ultimately, what I'm trying to get to is a field that I can use in a percentage line chart to plot this percent in question month over month.

Thank you again for any more help.
 
Then use:

sum({@ProdCorr},{V_BAR_SR_ACTIVITY.ACTIVITY_CREATED_DATE},"Monthly") % count({V_BAR_SR.BAR_ID},{V_BAR_SR_ACTIVITY.ACTIVITY_CREATED_DATE},"Monthly")

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top