MoneyWorks Manual
SumSelection ("filename.expression", searchExprOrSel)
Result Type: Number
Definition: Returns the sum of the nominated expression (which should be numeric) for the search expression for the specified filename. You may alternatively pass a selection variable instead of a string containing a search expression. When summing detail lines, use the SumDetail function.
Examples:
SumSelection("transaction.gross-amtpaid", "type = \"DII\"")
Returns the sum of all outstanding invoices (including unposted).
SumSelection("Name.dbalance", "D90Plus > 0")
Returns the total outstanding for all debtors who have invoices over 90 days old.
SumSelection("Name.dbalance-dcurrent", "DBalance > D.Current")
Returns the total overdue for all debtors with overdue amounts.
MWScript:
let sel = CreateSelection("Name", "*highlight") let sum = SumSelection("Name.dbalance-dcurrent", sel)
See Also:
CreateSelection: Create a selection of records
DisplaySelection: Display standard list window for a given selection of records
IntersectSelection: Intersect a selection with the result of another search
RecordsSelected: Count records in a selection or resulting from a (meta) search
SumDetail: Add up a field for details matching a search
UnionSelection: Add the result of another search to a selection