问题
So I've been asked to use Filemaker to put together a large DB consisting of some financial information, alongside other data. Coming from a MSSQL background, many of the commands seem abstract to me. One of the simplest I'd like is a summary of a value column based on a data type column:
DataType|Value
1 |10
1 |20
1 |10
2 |5
2 |10
I'd be looking for the result of DataType 1 = 40 and DataType 2 = 15. This would be straightforward in SQL using a GROUP BY clause etc, but I'm having issues in FM finding an area within the calculation field area to Sum a field (value) by changes in another (DataType).
Is there a way to do this directly, or would ExecuteSQL be the best option?
回答1:
The "native" way to do this in Filemaker is to produce a report, with records being sorted by DataType. Use a summary field, defined as Total of [Value] to provide the summaries. Place this field in a sub-summary part to show the sub-summary value for each sorted group. Place the same field in a grand summary part to show the overall total.
See also: http://www.filemaker.com/help/13/fmp/en/html/func_ref3.33.47.html#1029667
回答2:
Producing a report is just one of the "native" ways can do this. You can also do it via fields and calculations.
1. In your table set up a summary field that totals "Value"
2. Create a calculation using the function GetSummary ( summaryField ; breakField ) where summaryField= the field created in step 1 and breakField = DataType.
See FileMaker GetSummary info.
来源:https://stackoverflow.com/questions/27359976/filemaker-sum-by-group