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!

count by summary range

Status
Not open for further replies.
Jul 11, 2006
32
US
Crystal 10
I know about Group Sort but I can’t quite figure this out. I need to calculate the number of items within a price range. If I create a summary

sum({table.price}, item)

and I want to count the number of items within these price ranges:

$1 – 99
$100 – 499
$500 – 999
$1000 and over

I can use Top N to sort by the sum but I need a count of the number of items within each of the above ranges. Is this possible?
 
I'm a little confused by your formula sum({table.price},{table.item}), which implies there are multiple prices per item that you are adding together. Is this really what you are doing?

Or do you have a price per item and you want to group the items by price range and then count the items in the range?

-LB


 
Are you trying to count the number of groups that have a total in a particular range?

That would be tricky. What you could do is have separate counts for each of the range, which would test each group in the group footer. I think you'd need to use variables rather than running totals.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I have handled this with variables to total in the report footer not in a group footer since I can't create a group based on a summary. This works fine. Thank you for the advice.
 
You CAN create a group on a summary, by returning the summary directly in a command. Had you answered the questions, we could have helped you do that.

-LB
 
I am not offended. This is what you could have done--if I assume you meant exactly what you said in your first post. Start a new blank report->your datasource->add command and enter something like:

select sum(table.`price`) as sumprice,table.`item`
from table
group by table.`item`

The syntax/punctuation for the command would be specific to your datasource.

Then you could create a formula in the main report:

select round({command.sumprice})
case 0 to 99 : "$0 - $99
case 100 to 499 : "$100 to $499
case 500 to 999 : "$500 to $999"
case 1000 to 100000 : "$1000 or more"

Then you could insert a group on this formula and then place table.`item` in the details section and insert a count on it at the group level.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top