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

Trying to sum a groupName field and getting error

Status
Not open for further replies.

TurdFurguson

Programmer
Oct 13, 2004
3
US
Im using crystal 9 and trying to sum a groupName field.

I have a report with 6 grouping. The 6th group is Tax.

I want to sum the value in the group name of tax and not the actual tax?

my data looks like

inv num date tax amt units
1123 4/25 .30 12
1123 4/25 .30 8
1123 4/25 .30 6


inv num, date, and tax amt are my groupings so the report would look as follows
inv num date tax amt units
1123 4/25 .30
12
8
6

if i sum tax i get .90 and thats the wrong answer i want to sum the groupName so i tried a formula like this

sum(tonumber(GroupName ({Command.TAX})))

I get an error saying sum requires a field? Anyone have any ideas how I can sum the group name?

Thanks
 
What you're speaking of is called row inflation, and what you want to do is use something like:

maximum({Command.TAX},{command.inv_num})

At least I think that's what you want, hard to say because if you have several values per inv_num then it gets tricky.

-k
 
Thanks for your help synapse but that doesnt quite work. I put an extra row of data below and maybe that will explain m problem a little better.

inv num date tax amt units
1123 4/25 .30 12
1123 4/25 .30 8
1123 4/25 .30 6

1124 4/26 .45 10
1124 4/26 .45 8
1124 4/26 .45 11

inv num, date, and tax amt are my groupings so the report would look as follows
inv num date tax amt units
1123 4/25 .30
12
8
6
1124 4/26 .45
10
8
11

TOTALS .75 55

My problem is at the end I want to display a sum of all the units (that one is easy) and all the tax_amt... cept I dont want to add up all the tax amts I just want one tax amount per grouping. If i do sum(Command.units) that works .. but if I do sum(Command.tax_amt) i get 2.25 and that is too much tax, I expect .75. So I need to sum the value that is in the grouping and I cant figure that out.
 
I think you will have to create a group on inv num and date and then sum the tax amt, then you will get the right answer.

HTH
 
Why are you grouping by tax amt?

Anyway, to get a single value from the INV and DATE group, use:

maximum({table.tax},{table.date}) and place it in the date group header or footer.

To sum this, use a formula in the same location, such as:

numbervar TotTax:=Totax+maximum({table.tax},{table.date})

You can later display it using:

numbervar TotTax

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top