2 Replies Latest reply on Sep 24, 2015 6:28 AM by gregew

# Having trouble with functions nested in Sum function.

In the following calculation, I've tried to count (Sum) the number of only those text field entries that begin with an asterisk ("*").  I have six Fields to Sum, but I've simplified the calculation down to two for this posting:

Sum ( (not IsEmpty ( Channel1Num ) and If(Left (Channel1Num ; 1 );"*")); (not IsEmpty ( Channel2Num ) and If(Left (Channel2Num ; 1 );"*")) )

[For these two "Channel" fields, some records have text without leading asterisks, some have text with leading asterisks and some are empty.]

Obviously my syntax is wrong in trying to return a simple count if two conditions are True, so what is the correct way to do this?

Greg

[PS: I've also tried a version where the IF function returns a blank ("") if it's False.]

• ###### 1. Re: Having trouble with functions nested in Sum function.

You seems Summing in a record, then don't need Sum() function at all, use + instead.

(Left (Channel1Num ; 1 ) = "*" ) +

(Left (Channel2Num ; 1 ) = "*" ) +

etc.

Logical function returns 0 or 1, so you can omit If in this case.

• ###### 2. Re: Having trouble with functions nested in Sum function.

Thanks so much!  This was a great learning experience.  Boy, sometimes I can overthink a problem.  I don't work in FMPro that frequently, and so this will help me in how I approach future problems more logically.

Best regards,
Greg