Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Formula for concatenating multiple fields with "commas" to seperate values

Posted on 2016-08-03
4
Medium Priority
?
70 Views
Last Modified: 2016-08-05
Gurus,

I could use some help figuring out how to write a formula for this problem:

I have 6 separate currency fields to concatenate in one field.  I have to eliminate values of 0.  

I wrote a formula like this:
if isnull({field 1}) or {field 1} <= 0 then "" else Cstr({field 1}, 0, "") & "% Fiber"

I can't figure out how to include the commas (,) to separate more than one value or eliminate the comma if there's only one value.

The result would display something like this:
10% Fiber, 5% Protein

...or in cases where there's only one value:
10% Fiber


Can you help?

Thanks in advance!!

Steve
0
Comment
Question by:SStroz
  • 2
  • 2
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 41741642
Try this formula

Local StringVar strOut;

if Not(isnull({field 1})) AND  {field 1} > 0 then 
    strOut := " " & Cstr({field 1}, 0, "") & "% Fiber";
if Not(isnull({field 1})) AND  {field 2} > 0 then 
    strOut := ", " & Cstr({field 2}, 0, "") & "% Protein";
if Not(isnull({field 1})) AND  {field 3} > 0 then 
    strOut := ", " & Cstr({field 3}, 0, "") & "% String3";
if Not(isnull({field 1})) AND  {field 4} > 0 then 
    strOut := ", " & Cstr({field 4}, 0, "") & "% String4";
if Not(isnull({field 1})) AND  {field 5} > 0 then 
    strOut := ", " & Cstr({field 5}, 0, "") & "% String5";
if Not(isnull({field 1})) AND  {field 6} > 0 then 
    strOut := ", " & Cstr({field 6}, 0, "") & "% String6";

Mid(strOut,2)

Open in new window


mlmcc
0
 
LVL 7

Author Comment

by:SStroz
ID: 41741756
Thanks SO much mlmcc!  

I needed them to all be added together so I just added a "strOut"

strOut := strOut + ", " & Cstr({field 2}, 0, "") & "% Protein";

Thanks for pointing me in the right direction!!!

Steve
0
 
LVL 7

Author Closing Comment

by:SStroz
ID: 41741757
Thanks mlmcc!!!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 41745108
Sorry, that should have been in the solution

mlmcc
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

927 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