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!

Crosstab with percentage

Status
Not open for further replies.

Chumley40

Programmer
Jan 24, 2005
71
US
I have a crosstab that needs to look like this:
Jan Feb Mar
Total numberA 1 2 3
Average length 10 15 20
Percent numberA 25 10 50

I have the first two rows returning. But I can't figure out how to calculate the third row. Basically, row three is row 1 divided by the count of another field.

Any ideas?

I am using Crystal 8.5,
Chumley
 
You cannot do this type of calculation in a cross tab.

You will need to create dynamic formulae for each column up to the maximum number of columns you expect from your data.

Then you can use conditional suppression of each column tp only show the columns you require
 
Yes, you can do this in a crosstab. Chumley--you will have to specify what other field the percentage is based on. Also clarify whether row 1 is a count, a sum or what. It would help if you named the field(s) being summarized also.

-LB
 
I think my case is like this one so I will add on here. I'm using CR 8.5 and am connecting to a Gupta SQL db

I followed a link in this FAQ which helped me get started with calculating a percent in a crosstab. I have 3 summarized fields. I need the 3rd to calculate a percentage based on the previous 2 summary fields. There is 1 column for each month of the year. It's just a Comp sales report that I would like to look like this:

Depts Jan Feb
1 @sales2007 (sum)
@sales2006 (sum)
@compHolder (minimum)

I've got the first 2 summary fields showing correctly but not the third. I'm sure they're there but I can't find my mistakes in trying to do what the FAQ said. Right now the 3 field says 0.00%.

The suppress formula for the first two summary fields look like this using either 'Top' or 'Bottom' as my variable names:
WhilePrintingRecords;
numbervar Top:= {@$Sold-E};
False

For the third Summarized field, I used the formula for the currency symbol:
WhilePrintingRecords;
numbervar Top;
numbervar Bottom;

if Top <> 0
then totext((Bottom - Top) % Top) + '%'
else 'no' //put this in here to test

Can you see what I'm doing wrong? LB, is this how you were going to say how to do it?
 
cancel the request for help, sorry.

argh, I just figured out that CurrentFieldValue is really what I was supposed to write, not the value I wanted summarized. total "D'Oh!"

WhilePrintingRecords;
numbervar Top := [red]CurrentFieldValue[/red];
False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top