
1. Re: How to do a If this = that, then do a sum of X field?
ValBerechet May 3, 2015 4:04 PM (in response to ValBerechet)Seems like something is wrong with the Sum function on my end. I took out the If Type = "Sale" and just left Sum (Total System Size) and that is also blank, so need to see about getting that to work before I do any "If" calculations.

2. Re: How to do a If this = that, then do a sum of X field?
ValBerechet May 4, 2015 1:45 AM (in response to ValBerechet)Finally got everything working how I wanted it with a different method.
My field "Total Sale Price" was a Summary of "Sale Price" and my goal was to only show data from records where Type = Sale.
I ended up making a new field that said If (Type = "Sale" ; Sale Price) which basically only had the Sale Price data in it if Type = Sale.
I then made another field that was a Summary of the new field above and everything is working as indented. :)

3. Re: How to do a If this = that, then do a sum of X field?
philmodjunk May 5, 2015 7:34 AM (in response to ValBerechet)Here's why your first attempt fails. (The sum function works just fine, BTW):
If ((Type = "Sale") ; Sum ( Total Sale Price ))
If this is a direct copy/paste of your calculation. Sum ( Total Sale Price ) is only referencing the value of this field in the current record. If type = "sale", it returns the value of this single fieldwhich might be a summary field "grand total" value based on the current found set. If type does note equal "sale", then your IF function returns nothing.
Sum, even if Type = "sale" does not really do anything in this calculation.
If you look up the function in FileMaker help, you;ll find that there are 3 ways to use it:
Sum ( FIeld1; field2; field3 ) which will be the total Field1 + field2 + field 3, all from the same record
Sum (RepeatingField) which will be the sum of all values of all repetitions of this field, all from the same record
Sum (RelatedTable::Field) which is the most common way to use this function, It sums field over the set of all related records, such as all the recors showing in an unfiltered portal.
You appear to be using Sum ( Field1 ), which will simply return the value of Field1. Then you enclosed it inside an If function that either allows the function to evaluatereturning the value of field1 or does not allow it to evaluatereturning nothing.
There are several other methods that can selectively sum data from multiple records besides the method you worked out.
ExecuteSQL can use sum with a WHERE clause to selectively sum data.
Sum ( RelatedTable::field) can selectively sum, if you set up the relationship to the related table to match only to the records you want to sum. (This can be a "self join" with two occurrences of the same table on each side of the relationship.)
In a summary report, a simple summary field can display sub totals if you place the summary field inside a sub summary layout part.
Filtered portals with a summary field inside the portal row can show a total of just the related records that pass the filter expression