Solved

Add Zero's to Crystal Report String

Posted on 2003-12-02
14
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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