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!

"Packed" field

Status
Not open for further replies.

teknogeek9

Programmer
Jan 6, 2001
47
0
0
US
I have an varchar "amount" field that looks like this:
6231883.48;5619475.63;6163582.29;5774570.44;4234819.62;0;0;0;0;0;0;0;0

Each bucket represents a month plus the 13th month. I am open to ideas as to how to break this up into separate buckets.
 
You can use the Split() function to break up each month. For example, this will give you the first "month's" value from the string:
[tt]
Split({Table.StringFieldToSplit},";")[1];
[/tt]
-dave
 
Dave...
Thanks...that is what I was thinking but then that means I will have to create 26 separate formulas.
Sam
 
If it's just for display, then you can use :

Local StringVar String := "6231883.48;5619475.63;6163582.29;5774570.44;4234819.62;0;0;0;0;0;0;0;0";
Local StringVar Array Values := Split(String,";");
Local StringVar Result := "";
Local NumberVar Counter := 0;
While Counter <> UBound(Values) Do
(Counter := Counter + 1;
Result := Result &Space(12-Len(Values[Counter]))& Values[Counter];);
Result;

Replace the item in bold with your field name.

Reebo
 
You state that you want 26 different buckets, but complain that it requires 26 different buckets.

Depending upon the database, you might resolve this longterm by creating a View on the database so that all processes can use an intelligent data source which exposes all of the fields.

To just display them all in rows, try:

join(Split({Table.StringFieldToSplit},";"),chr(13))

This is dependent upon your version of Crystal.

You've haven't shared your environment nor requirements, so it's difficult to assist you.

-k
 
there is no need for 26 different formulas it is done all at once in one declaration

stringvar array Bucket := split({table.field},";");

now you have an array of 26 elements ...or rather the number that exist in the string....they are as strings but easily can be converted to numbers later if needed for calculations

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Thanks for your assistances. For now, I can't do much since I have ver. 8.5 and that is limited to 255 char whereas the field is 520. The long-term solution, obviously, is going to be a view.
Sam
 
You might use SQL Expressions to break the field into 2 fields, and then you can use this function against them.

Or you might even build out the 26 fields using SQL Expressions, but you're better off to do all of this in a View or SP.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top