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

Sort On A Formula

Status
Not open for further replies.

Readymixer

Technical User
Oct 23, 2003
7
US
I am trying to sort on a formula that looks like this:

IF Sum ({KR_CustProfAnalysis1.Quantity}, {@CustQuote}) < 0
//THEN 1
THEN -(Sum ({@NetProfit}, {@CustQuote})/Sum ({KR_CustProfAnalysis1.Quantity}, {@CustQuote}))
ELSE IF Sum ({KR_CustProfAnalysis1.Quantity}, {@CustQuote}) = 0
//THEN 2
THEN -(Sum ({@TotalCost}, {@CustNumbName}))
ELSE Sum ({@NetProfit}, {@CustNumbName})/Sum ({KR_CustProfAnalysis1.Quantity}, {@CustNumbName})

The formula is referecing a view on my database. The result is a Number data type. Crystal is not giving me the above formula as a selecting in the Sort Order tool in Crystal 8.5. What am I missing?
 
Have a look at the topN expert.

Sorting, by definition, is for detail records, not summary records as your post indicates.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
What you need is a topN/group sort, but TopN only works with inserted summaries. The only solution I've found within CR is to recreate the summary using SQL expression(s). You can then insert a maximum or minimum in order to make the expression available for sorting by topN. If you want help with this approach, you would need to provide the contents of all your nested formulas, and also provide your record selection formula.

Otherwise, you could try some other mechanism (creating the summary in the view) to create a "hard value" for inserting a summary.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top