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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Product Weight from description

Status
Not open for further replies.

strom99

MIS
Nov 28, 2000
126
US
I have the following field

55 gal container (750 lb, 341 kg)
Holder (11 lb, 5kg)

I need to be able to extract the 750 lb, 341 kg in order to sort on this field.

Crystal 8.5

Thanks!
 
Dear Strom99,

If this is always the format you show above, then this formula should work:

Mid({Table.WeightField},instr({Table.WeightField},"("),length({Table.WeightField}))


This will return (750 lb, 341 kg)

If you need to remove both parens adjust to this:

Mid({Table.WeightField},instr({Table.WeightField},"(")+1,length(Mid({Table.WeightField},instr({Table.WeightField},"(")+2))))

Hope that helps,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Since these are the same, with two different measurement systems, and since you want to sort (meaning you want numeric values):

if isnumeric(mid("Stuff (750 lbs )",1+instr("Stuff (750 lbs )","("),1)) then
val(mid("Stuff (750 lbs )",1+instr("Stuff (750 lbs )","("),
instr("Stuff (750 lbs )","l")-(1+instr("Stuff (750 lbs )","("))))
else
0

Replacing
"Stuff (750 lbs )"
with your field name.

This also verifies that it's a number after the first ( character and returns 0 (so they would sort first).

-k kai@informeddatadecisions.com
 
Perhaps I should clarify why you need a numeric:

Given the values:

(1 lb...)
(2 lb...)
(10 lb...)
(100 lb...)
(200 lb...)
(9 lb...)

If it's a string, then you'd get the following sort:

(1 lb...)
(10 lb...)
(100 lb...)
(2 lb...)
(200 lb...)
(9 lb...)

If it's a value, you'd get:

(1 lb...)
(2 lb...)
(9 lb...)
(10 lb...)
(100 lb...)
(200 lb...)

Remember, you don't have to show the field you sort on, it simply allows for proper sortation.

-k kai@informeddatadecisions.com
 
Dear SV,

I hadn't thought that through for him as regards the sorting....

Your solution is much better!

Thanks,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top