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

Rounding in a cross-tab 1

Status
Not open for further replies.

RenaG

Programmer
May 3, 2011
132
0
0
US
Does anybody know how to control what shows in a cross-tab when you show the percentages? The one I created seems to truncate the decimal value. So if the percentage is .9 it will display a 0%. Or a 1.9% displays as a 1%. It makes the table look like something is missing when the values don't add up to 100%. I tried playing with the format field option but it doesn't do anything.

TIA!
~RLG
 
Yes, you can do this. Please see thread767-1618522. If you need further help, please identify your row field, column field, and summary fields, including type of summary.

-LB
 
Hi lbass,

That link did the trick. Thanks! Trying to figure out what to search for can be half the battle ;-)

I modified the totext slightly so that it rounded the value:
Code:
totext(Round(curr%tot)) + "%"

It still shows the decimal places; ie. 4.00%. Is there a way to remove the decimal values? I thought that the round would do that for me. I tried Int and Truncate but neither worked.

Thanks again for your invaluable help!

~RLG
 
I thought you WANTED the decimals.


Change the display string formula to:

whileprintingrecords;
numbervar curr;
numbervar tot;
if tot = 0 then
"--" else
totext(curr%tot,0) + "%" //0 for 0 decimals

If you wanted to show two decimals, you would use:

totext(curr%tot,2) + "%"

-LB
 
You are absolutely correct - that IS what I wanted.

I was just playing around with it thinking that in the future I may want to drop the decimal places.

If it's not too complicated, could you explain why we put the first two formulas on the Suppress x+2?

~RLG
 
It has nothing to do with suppression, really. We are just using those formula areas as a (behind-the-scenes) place to calculate running totals using variables set to the values in the cell (currentfieldvalue).

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top