I have to laugh because every day that I show my boss the "new" version he keeps asking me to add "just one more thing."

This time I would like the portal to add up all the days that show a checkbox and not the ones that don't have a checkbox.

I put in a field called "Include", made it into a checkbox that has one custom value: "Y"

When I put it into the portal the field which sums the total comes out with the wrong total shown below:

It should show a total of 100.

The sum field (Total Course Days) has a calculation of:

Sum ( Sections::NoOfDays; Sections::chk_Include = "Y" )

What did I do wrong?

Sum ( Field1 ; Expression ) is another way of writing:

Field1 + Expression

Sections::chk_Include = "Y"

Is an expression that evaluates to produce only two possible results: 1 (TRUE) or 0 (FALSE)

When an expression in FileMaker has this format:

RelatedTable::Field

There might be a million related records that link to your current record, but the expression only refers to the value of the "first" related record. In an unsorted relationship, the first related record is the oldest related record (The first one to be created).

Thus you are getting 60 + True or 60 + 1 which is 61.

Sum has no "conditional parameter" capability. It simply either sums the listed fields, or if used in this format:

Sum ( RelatedTable::Field )

Sums up all the values of Field of those related. It can't "pick and choose" which related values to sum.

You have several alternative approaches possible:

Set up a relationship different from that used for your portal that only matches to included records. Then sum (RelatedTable::Field ) will work.

Define a summary field in the related table that totals this field. Put this summary field inside a one row filtered portal where the portal filter expression excludes all records where the check box is not selected.

Use ExecuteSQL with the Sum function and a WHERE clause that only selects the fields that are included and that appear in this portal.