Solved

How can you sum comma separated numbers within a string?

Posted on 2008-10-10
3
455 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now