Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Select text, conv to numb compare Post Reply Post New Topic
Author Message
mabrown
Newbie
Newbie


Joined: 08 Jun 2007
Online Status: Offline
Posts: 27
Quote mabrown Replybullet Topic: Select text, conv to numb compare
    Posted: 27 Nov 2012 at 8:23am
Hello,

I am trying to do a comparison on the pkg size of two items. Each line below is in one text field so I need to extract the text quantity, convert text to a number and then compare the numbers. (The comparison is no problem but I can't seem to get the text out.)

The text field length varies but the number is always at the end. The package size format can vary as well. IE. Pkg/100 or Pkg 100.

widget 3 1/2" blue Pkg/100
widget 3 1/2" blue Pkg/10

Baby blue Caddy with pink trim Pkg 100
Baby blue Caddy with pink trim Pkg 10
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 27 Nov 2012 at 8:31am
You might be able to extract the number by using the InStrRev function along with the Right function.  The problem arises with two different kinds of delimiters for the number (a space or a slash).  The other way that might work better is use the Mid function and start at the right side of the string and work backwards until you find a non-numeric character.

I hope this helps.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 28 Nov 2012 at 1:22am
Hi
 
Try this :
 
If trim(replace(Mid({Sheet1_.Description},instr({Sheet1_.Description},'Pkg'),20),"Pkg"," ")) startswith "/" then
Tonumber(replace(trim(replace(Mid({Sheet1_.Description},instr({Sheet1_.Description},'Pkg'),20),"Pkg"," ")),"/"," "))
else
Tonumber(trim(replace(Mid({Sheet1_.Description},instr({Sheet1_.Description},'Pkg'),20),"Pkg"," ")))
 
Note : replace '{Sheet1_.Description}' with your database field name
 
 
Thanks,
Sastry
IP IP Logged
mabrown
Newbie
Newbie


Joined: 08 Jun 2007
Online Status: Offline
Posts: 27
Quote mabrown Replybullet Posted: 28 Nov 2012 at 10:10am
I had some time to play with it today and this part works now I just need update the rest of the report.
THANK YOU
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.