Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I really enjoy your site. You have a lot of helpful and friendly experts who contribute so willingly. Thank you for past (and future) technical advice..."

Geography

Where in the world do Tek-Tips members come from?
commacoma (TechnicalUser)
24 Apr 12 5:04
Hello!

I'm creating a report on stock, and need the figures to accurately total remaining stock after movements.

The database holds the total quantity of stock moved in each transaction, and it's direction of movement (so either in or out).

The direction is a string (either - or +) and quantity a number. I need to combine these and convert to a number so I can run a sum on them, but have not been able to do this so far.

The below puts them in a string, but does anyone know how I can convert these to a number. When I try 'tonumber' I get 'The String is Non Numeric'.

{trans_detail.direction}&{trans_detail.qty-adjust}

Thanks!

Madawc (Programmer)
24 Apr 12 5:46
Just what is the data?  And what have you used to convert?

Saying something like

CODE --> @NumericDirection

ToNumber({trans_detail.direction})
should be fine.

yinyang Madawc Williams (East Anglia, UK).  Using Crystal 2008 with SQL and Windows XP yinyang  

commacoma (TechnicalUser)
24 Apr 12 6:55
Thanks for the reply, but I still get the 'The String is Non Numeric' error.

The only data that's held in {trans_detail.direction} is either a - or + sign. I need to add it on to the number in {trans_detail.qty-adjust} in order to make it either a positive or negative figure.

lbass (TechnicalUser)
24 Apr 12 8:56
YOu could create a formula like this:

if {trans_detail.direction} = "-" then
-{trans_detail.qty-adjust} else
{trans_detail.qty-adjust}

-LB
commacoma (TechnicalUser)
24 Apr 12 9:18
Ah perfect, knew it'd be something simple! smile Thanks!

andrebrazil (TechnicalUser)
26 Apr 12 13:19
Another solution

I created two formulas


{Plan1_.in/out} is the column with '+' or '-'
{Plan1_.value} is the column with the value


@pos-neg
Shared numberVar value:=0;
WhilePrintingRecords;
If {Plan1_.in/out}=trim("-") then
value:=-1
else
value:=+1

@Final
global numberVar  value;
{Plan1_.value}*{@Pos-neg}

 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close