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!

Percentage with decimals in Crosstabs 1

Status
Not open for further replies.

skurkal

IS-IT--Management
Apr 6, 2005
37
US
Hi All,

I am using CR XI R2, and have a crosstab with percent. I would like the percent to show with values upto 2 decimals.

Total va md
Total 1,631 100% 1,352 82% 13 0%
IM 59 100% 58 98% 0 0%
Phone 926 100% 690 74% 10 1%
VM 20 100% 13 65% 0 0%
WC 70 100% 64 91% 0 0%
Fax 556 100% 527 94% 3 0%


My totals are counts and I used the sugessions by Lbass of using the following :

For the va and md colums I use
whileprintingrecords;
numbervar curr := currentfieldvalue;
false

For the total column I used
whileprintingrecords;
numbervar tot := currentfieldvalue;
false
So that should store values 1631,59,936,20,70,556 in the tot variable


And for the % values I used,
whileprintingrecords;
numbervar tot;
numbervar curr;
totext(curr%tot,2)+"%" //2 for 2 decimal

But this seems to store 556 as the total all the time. What am I doing wrong?

Thanks for your help in advace,
s.




 
Please identify your row, column, and summary fields. How many instances are there of your column field?

-LB
 
Row are interactiontype and colums are regions, summary is the count of the interactions by region along with the percentage.

so for interaction type of phone, I have

Total VA MD
phone 926 100% 690 74% 10 1%

I want this to show up as :

Total VA MD
phone 926 100% 690 74.51% 10 1.07%

Hope this is clear.
Thanks!
 
Forgot to show the summary columns in the last post, I am going to simplify the crosstab.

So it is : Row are interactiontype and colums are regions, summary is the count of the interactions by region along with the percentage. There is a tot of the rows on the left and total of columns on top.

Total VA MD
Total 50 100% 24 48% 26 52%
Phone 20 100% 15 75% 5 25%
Email 30 100% 9 30% 21 70%


So in order to show the decimals in the percent, I put all the values shown in "" into variable tot and all values shown in '' into variable curr and for the percent divided curr by tot. But that did not do it right, It keeps the last value ie 30 in tot and divides everything by 30.

Total VA MD
Total "50" 100% '24' 48% '26' 52%
Phone "20" 100% '15' 75% '5' 25%
Email "30" 100% '9' 30% '21' 70%

Sumitra.



 
You have to approach this a little differently, since you are aiming for percentages based on row totals. First, insert a group on {table.interactiontype} in your main report (suppress it if you wish). Then create two formulas:

//{@grtot}:
count({table.interactionID})

//{@rowtot}:
count({table.interactionID},{table.interactiontype})

Add both of these as summaries in your crosstab somewhere above the percentage summary, using maximum as the summary type in each case. Then use {@grtot} for the "tot" variable for the total row (top row) for both inner cells and the left hand grand total, and use {@rowtot} for the total column (left column) and the inner cells for the "tot" variable. In each case, change the false to true, so that these totals are suppressed. When you are not using them (e.g., {@grtot} in the inner cells), just suppress them directly. Then grab the boundaries of these two summaries and resize them, making them as narrow as possible. Leave the other formulas as they are, except make the following change to your display formulas:

whileprintingrecords;
numbervar tot;
numbervar curr;
if tot <> 0 then
totext(curr%tot,2)+"%" //2 for 2 decimal

-LB
 
Thanks Lbass! this worked wonderfully. Took me a little bit but everything fell in place. Percents based on column totals is straight forward but this is a little round about. Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top