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!

How to sort report by Formula Field? 1

Status
Not open for further replies.

Katya85S

Programmer
Jul 19, 2004
190
In Crystal report i'm working on several Formula Fields are used.
Let's say, the Formula Fields are @A, @B, and @C. I need to sort report by Formula Field @C which is a difference between @A and @B (@C=@A-@B).
@C field is not appearing in my sorting options when i hit the Sorting Icon.
How can i do this?
Thank you all in advance.
 
Hi,
Do @A and @B appear?

Is @C at the same level in the report as @A and @B?

I cannot reproduce the problem..all 3 formulas I created show up..

Also, What vserion of CR?

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
@A is compound of 2 other Formulas and is not appearing either (@A= {@MonthlyAveBr}/{@TargTr}). @B is a long list of IF-THEN conditions and, yes, @B appears in the sort option.
To make it cleare @B is:
if {br_nbr} = 01 then 2 else
if { br_nbr } = 02 then 2.48 else
if { br_nbr } = 03 then 3.84 else
if { br_nbr } = 04 then 4.06 else
if { br_nbr } = 05 then 4.53 else
if { br_nbr } = 06 then 1 else
and so on
if { br_nbr } = 21 then 3.5 else
0

the CR version used is 8.5
 
The problem appears to be that your formulas contain summaries. You should always post the contents of all formulas, including nested formulas, as they can affect what solutions are suggested.

-LB
 
Here those formulas are:
@MonthlyAveBr=Count ({tr.Tran_Code}, {br.br_name})/5
and @TargTr formula is:
if {br_nbr} = 01 then 2000 else
if { br_nbr } = 02 then 2356 else
if { br_nbr } = 03 then 2222 else
if { br_nbr } = 04 then 4444 else
if { br_nbr } = 05 then 1234 else
if { br_nbr } = 06 then 1333 else
and so on
if { br_nbr } = 21 then 2345 else
0
I hope my question makes sense now.
Is there a way to sort the report by @C?
Thank you all.
 
Create a SQL expression (if this is an option available in your field explorer) like this {%count}:

(select count(A.`Tran_Code`) from tr A, br B where
B.`br_name` = br.`br_name`)

Depending upon your report selection criteria, you might need to add other criteria to this, since this evaluates at the database level (not based on records returned to the report).

Then use this in the following formula {@A}:

{%count}/5

Now {@C} should be available to use in the record sort area.

-LB
 
lbass, Many-Many thanks!!! It works.
I appreciate your help very much! Thank you! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top