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!

Sorting based on a formula field... 1

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
US
Hi All!

I'm trying to put together a report in Crystal Reports 10. The report contains 3 groups. The third of them groups by a database field called 'description'. This is how the report looks when it's printed:

[tt] GROUP 1 VALUE 1
Group 2 Val 1

Animal Type Count %
Cats 15 20.3
Dogs 20 27.0
Fish 13 17.6
Hamsters 26 35.1
----------------------------
Total 74 100.0
[/tt]

The words Cats, Dogs, Fish and Hamsters are coming from that 'Description' database field I mentioned before, and my third group is based on this field. I placed the description field on the footer of group 3 and that's where those animal types are coming from. To get the count of each animal, I create a formula which I put in the details section. The formula simply says this:
[tt]
if storeId = x then
1
else
0[/tt]

where x is the Id of the store where the animals are (the report is supposed to print up to six stores side by side, and I have a different count formula for each store.)

Ok - so far so good!

Here's what I need. The list of animals is sorted by its description. I need to sort it based on the Count of animals in descending order. So, in the example above, the animals should be in this order:

Hamsters (26)
Dogs (20)
Cats (15)
Fish (13)

Any idea how to do it?

Thanks!

JC

_________________________________________________
To get the best response to a question, read faq222-2244.
 
Go to report->topN/group sort (not sure where this is in CR10)->choose the group tab for Group #3->choose "sum of {@storeID}" or whatever the name of your original formula is->descending.

-LB
 
Beautiful!

(I shouldn't use 'TopN' though, as I want to display all animals, so I just used the 'All' grouping option.)

Thanks, and here's your star!

JC

_________________________________________________
To get the best response to a question, read faq222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top