Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress Leading Zeros of a Summary

Status
Not open for further replies.

slicknick515

Technical User
Aug 27, 2009
15
0
0
US
I use the formula below to suppress leading zeros of a number but i want to replace the {FIELD1} with the (Sum of {FIELD1})

Is this possible?

WhileReadingRecords ;
StringVar text := Totext ( {FIELD1} , 4 , "" ) ;
NumberVar end := length ( text ) ;
NumberVar clip :=
(if Val ( text [ end - 4 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 3 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 2 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 1 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 0 to end ] ) = 0 then 1 else 0 ) ;
text [ 1 to Length ( text ) - clip ]
 
Why do you need to do this? If you just add the number or summary to the report without converting it to text, there would be no leading zeros, and you can format it as you wish using field formatting.

-LB
 
slicknick,

If your current formula works for removing the leading zeros, you *should* just be able to replace {Field1} with Sum({Field1}). This will be the sum of the field for the entire report. For the sum of the current group, the syntax is Sum({Field1},{GroupField}).

I am unsure as to your choice of approach, there are likely more simple (or other) means to acheive this. [smile]

Hope this helps!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Baically, i am using this formula to show the patient's dose. If the dose is not a whole number, it shows that number up to four decimal points. If it is a whole number, it clips the zeros. In my group footer, i have a summary of the dose and i want to treat it the same way with the leading zeros. I tried replacing the Field with the Sum of the Field and the error says that it has to be evaluated later.

If you have a better way, please let me know.
 
slicknick,

If you can provide some sample data (from the details level), we can see if there is a better approach. If you have any formula fields at this level, please include the formulas. If it is stating the value must be evaluated later, I am thinking you may have a running total, or some other such field.

If the above works, there is nothing wrong with it - I have just not seen a formula like yours for this purpose before. [smile]

If it isn't broken, no sense fixing it!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
I believed you when you referenced "leading zeros". What you really are doing is removing "trailing" zeros. Just get rid of the "whilereadingrecords"--which is unnecessary, and plug in the sum, as in:

StringVar text := Totext(sum({FIELD1}),4,""); //etc.

Or, if it is a group sum:

StringVar text := Totext(sum({FIELD1},{table.groupfield}),4,"");//etc.

-LB
 
Sorry, I did mean trailing zeros. Taking the "while reading records" resolved this issue. Thanks so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top