Solved

Add Zero's to Crystal Report String

Posted on 2003-12-02
14
416 Views
Last Modified: 2008-03-10
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.

Thanks in advance!  
0
Comment
Question by:cybrthug
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 9861403
ToText({@total},"0000000.00")

Pete
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9861450
@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 Comment

by:cybrthug
ID: 9861774
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9861913
Try this:
ReplicateString ("0", 10-Length(CStr({field1.number} + {field2.number} + {field3.number}))) & CStr({field1.number} + {field2.number} + {field3.number})
0
 

Author Comment

by:cybrthug
ID: 9861964
Still showing only one field unfortunately. I feel we are so close, gotta be something missing.
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9861988
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 9862383
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cybrthug
ID: 9866465
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9867945
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 Comment

by:cybrthug
ID: 9868213
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 9871591
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
 
LVL 19

Accepted Solution

by:
Dexstar earned 300 total points
ID: 9875654
@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
 

Author Comment

by:cybrthug
ID: 9876418
Thanks again Dexstar, thats all it took was an extra group with subtotals.
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9876446
Okay, good!  I thought I was going crazy or something...  :)

Dex*
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now