Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add Zero's to Crystal Report String

Posted on 2003-12-02
14
Medium Priority
?
423 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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 101

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 101

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 1200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

604 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