Solved

Add Zero's to Crystal Report String

Posted on 2003-12-02
14
414 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
Comment Utility
ToText({@total},"0000000.00")

Pete
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
@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
Comment Utility
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
Comment Utility
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
Comment Utility
Still showing only one field unfortunately. I feel we are so close, gotta be something missing.
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:cybrthug
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
@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
Comment Utility
Thanks again Dexstar, thats all it took was an extra group with subtotals.
0
 
LVL 19

Expert Comment

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

Dex*
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

11 Experts available now in Live!

Get 1:1 Help Now