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!

Sorting by a formla field

Status
Not open for further replies.

arodri

Technical User
Jul 9, 2010
121
US
Hello,
I have a Crystal report that is being generated by a stored procedure in a SQL database. My report has two groups, region and employee name. All of my data is in the footer of the employee name field, and every column in my report is a formula. I am also suppressing any employee that has @CARS=0. (@Cars is my first column, and is used as the denominator for a division in another formula).
One of the columns, "Total RP" is a formula field which is simply a sum of two other previous fields (also forumlas). I need to order my report by "Total RP" descending. Any ideas on how to do this?

I looked in the "record sort oder" option but only report fields and database fields are available, and I need a forumla field. The "group sort order" option is greyed out so I am not able to see if that will help.
I am using Crystal Reports XI. Any help would be greatly appreciated as I really need to do this...thanks!
 
You need to show the content of Total RP and of any nested formulas. Also explain what tables you are using in the report and how they are linked, since you might need to use a SQL expression to accomplish this.

-LB
 
I am not using any tables, just a stored procedure. In the stored procedure I'm selecting fields from different tables, but my data source for this report is just the stored procedure.

"Total RP" is a formula (@TotalRP) and it's basically: @ExtraRP+@DetailRP (I'm note sure if it's important but both @ExtraRP and @DetailRP are also forumlas. They are both the division of two running totals).
"Total RP" takes two of the previous columns and sums them up to get a dollar amount for each employee. This is the column I need the entire report sorted by.


I hope this answers your questions- if not I can definitely try to clarify it.

 
Your best bet is to create the summaries used in the formulas directly in the stored procedure by creating subqueries so that you can use a formula in the main report that you are able to insert a summary on--which is a requirement for activating the group sort. This means that you would have to be able to calculate the summaries without using running totals, by using conditional formulas, for example. I can't really make further recommendations without knowing more.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top