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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF THEN

Status
Not open for further replies.

pungigi

Programmer
Oct 29, 2003
115
US
Ok,

I have a report that shows the following
Total Cst NS Cst Avg Cst Rank
Advance C 7852.50 135.00 33.85 1
Crosstown C 0.00 0.00 0.00 1
Riverbend C 4450.00 52.50 44.00 1

Rank 36.61
Rank 2 40.27
Rank 3 43.93
Rank 4 47.59

Ok, RN should be a formula that says if AVG CST is
Less than rank put a 1,
greater than rank but less than rank 2 put a 2,
greater than rank 2 but less than rank 3 put a 3,
greater than rank 3 put a 4

This is what I currently have and it doesn't work.
if {@Avg Cost}<>0
then if {@Avg Cost}<={@Rank}
then 1
else if {@Avg Cost}<={@Rank 2}
then 2
else if {@Avg Cost}<={@Rank 3}
then 3
else if {@Avg Cost}>{@Rank 3}
then 4

Crystal Reports 9

TIA for any help.
 
What's the error or result you're getting?

jennifer.giemza@uwmf.wisc.edu
 
What are the contents of formulas {@rank},{@rank2},{@rank3},{@rank4}? Are they also summaries of some kind? Please also show us the fields that contribute to the summaries in your example.

-LB
 
SORRY, the error I am getting is it returns a 1 for everything.

@AVG COST FORMULA
if {@Total Trips}<>0
then ({@Comp Cost}+{@NS $ Paid})/{@Total Trips}
else 0

@RANK FORMULAS
@RANK AVG COST {@Rank Cost}/{@Rank Count}
@RANK {@Rank Avg Cst}
@RANK2 {@Rank Avg Cst}*1.1
@RANK3 {@Rank Avg Cst}*1.2
@RANK4 {@Rank Avg Cst}*1.3
@RANK COST Sum ({_MTMTRP.TNOSHO}, {_VENGEO.VST})+Sum ({@Comp Cost}, {_VENGEO.VST})
@RANK COUNT Sum ({@Comp Count}, {_VENGEO.VST})+Sum ({@NSs}, {_VENGEO.VST})+Sum ({@Vdr NSs}, {_VENGEO.VST})+Sum ({@Vdr Cxls}, {_VENGEO.VST})

Let me know if you need more, I hope this provides you with enough.
 
I don't think we can really troubleshoot this without knowing a lot more about your report and the contents of all formulas--you have formulas within formulas within formulas. So I suggest that you might troubleshoot this by placing each rank formula next to the avg cost (I guess this is in a group header or footer) and see if the values are what you expect for both avg cost and each rank.

If the rank amounts are inflated, you should then look at the detail section to see if you have duplicate values that are inflating your sums.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top