# Add Zero's to Crystal Report String

Ive got a Report that has the formula TOTAL and it SUMs 3 fields like:

{field1.number} + {field2.number} + {field3.number}

this comes out to be:

66.50

What i need the report column to show from that formula is:  0000066.50

Only tricky part is keeping the report column with 10 characters including the period but i need
all 10 characters to fill it so 0's are needed.

If i only have 5.00 show up then i need 0000005.00 with an extra 0.

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
ToText({@total},"0000000.00")

Pete
0
Commented:
@cybrthug:

> Only tricky part is keeping the report column with 10 characters including
> the period but i need
> all 10 characters to fill it so 0's are needed.

> If i only have 5.00 show up then i need 0000005.00 with an extra 0.

Add another formula with this equation:
ReplicateString ("0", 10-Length(CStr({@TOTAL}))) & {@TOTAL}

And then use that formula on your report.

Hope That Helps,
Dex*
0
Author Commented:
For some reason both your answers come up with the same, they are not calculating
the TOTAL but showing only one field with the zero's.

TOTAL looks like this:

{field1.number} + {field2.number} + {field3.number}

and I made ZEROFILLTOTAL

with both of the answers above and they come out the same with the appropriate amount of zero's just not SUM'd up. Only one of the fields values are being used.

0
Commented:
Try this:
ReplicateString ("0", 10-Length(CStr({field1.number} + {field2.number} + {field3.number}))) & CStr({field1.number} + {field2.number} + {field3.number})
0
Author Commented:
Still showing only one field unfortunately. I feel we are so close, gotta be something missing.
0
Commented:
It is only SUPPOSED to show one field.  That field is supposed to be the SUM of 3 fields.  Are you saying that it isn't the SUM, it is just the value of one of the 3 fields?  Which field is it using?  Maybe those other fields are blank, so they do not contribute to the sum at all?

Dex*
0
Commented:
Your original formula was working?

TOTAL
{field1.number} + {field2.number} + {field3.number}

I assume it was something more like {View.Field1} + {View.Field2} + {View.Field3}

Create a new formula
Format10Characters
cstr({@Total},"0000000.00")

mlmcc
0
Author Commented:
Yea same output mlmcc, maybe i need to get a little more indepth of what im trying to do.
Ive got a worker and he's working 5 days a week, ive got a summary of the total sum of hours for that week with the hours he's accumulated which are those 3 fields. Form some reason the formula you guys are showin me isnt reflecting the summary total for the week, but it is working as far as formatting. Its only reflecting the 3 fields with no summary for the entire week.

I hope some of that makes sense :)
0
Commented:
Can you give an example of the exact values you are seeing, and compare them to what you were expecting.  I'm not sure I follow what you mean by "only reflecting the 3 fields with no summary for the entire week".

Dex*
0
Author Commented:
Ok ive got a worker, he has regular hours, overtime hours, and double hours. These are the 3 fields.  The worker has worked say these hours below.

Mon  -  8 hours regular,  4 hours overtime, 0 hours dbl
Tue  -  8 hours regular,  2 hours overtime, 0 hours dbl
Wed  -  8 hours regular,  0 hours overtime, 0 hours dbl

Currently i have it totaling those three fields, and then doing a summarize on the total for the entire week. With what you guys have suggested above it only seems to get the last day. Im trying to keep the working summarized field that i have now and add the extra zero's.
0
Commented:
Formulas by themselves are not cumulative over records.  Rather a formula is used to calculate something for a given record.

I think you can do what you want with a running total or using variables in the formulas.

Look at this for running totals
http://support.crystaldecisions.com/communityCS/TechnicalPapers/scr_running_total.zip.asp

Look at this for variables
http://support.crystaldecisions.com/communityCS/TechnicalPapers/scr_variablescopes.pdf.asp

mlmcc
0
Commented:
@cybrthug:  Do you have any groups?  I think you want to have a group for each person, and then a group for each week, and then list out the entries for that week.  Then you can subtotal by person and then subtotal again by week (or vice versa).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Thanks again Dexstar, thats all it took was an extra group with subtotals.
0
Commented:
Okay, good!  I thought I was going crazy or something...  :)

Dex*
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.