Solved

How can you sum comma separated numbers within a string?

Posted on 2008-10-10
3
456 Views
Last Modified: 2010-04-21
I have a string field in my data base.  Examples are:
0;3;4;2;3;5;0
3;4;1;20;3;0;4

I want to create a field that shows the sum of this field.

Results:
17
35

Is there an easy way to do this?
0
Comment
Question by:benbelzer
3 Comments
 
LVL 3

Expert Comment

by:Spydergt
ID: 22692243
Are there always 7 numbers?  If so it may be easy to break it down trimming to the commas in a formula.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 22692339
Try this

WhilePrintingRecords;
Local StringVar Array MyNumbers;
Local NumberVar i;
Local NumberVar Total;

MyNumbers := Split({YourField},';');
For i := 1 to UBound(MyNumbers) do
    Total := Total + Val(MyNumbers[i];

Total

mlmcc
0
 

Author Closing Comment

by:benbelzer
ID: 31505231
Flawless... thank you!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question