4.8 Spreadsheets with details and summary

A common organization for spreadsheets is to have a bunch of “detail” rows, each perhaps describing a transaction, and then a set of “summary” rows that each show reduced data for some subset of the details. SES supports this organization via the ses-select function.

(ses-select fromrange test torange)

Returns a subset of torange. For each member in fromrange that is equal to test, the corresponding member of torange is included in the result.

Example of use:

(ses-average (ses-select (ses-range A1 A5) 'Smith (ses-range B1 B5)))

This computes the average of the B column values for those rows whose A column value is the symbol ’Smith.

Arguably one could specify only fromrange plus to-row-offset and to-column-offset. The torange is stated explicitly to ensure that the formula will be recalculated if any cell in either range is changed.

File etc/ses-example.el in the Emacs distribution is an example of a details-and-summary spreadsheet.