MoneyWorks Manual
TableAccumulate (tab, key, value1, ...)
Result Type: Table
Definition: Accumulates values into a table of key/value(s) vectors, allowing you to build your own analysis tables. Each time TableAccumulate is called, it locates the row in table tab whose first value is key, and adds the specified values to it. If no row is found, one is created. You would normally use TableAccumulate in a report For loop when you are stepping through a range of records. Note that the first row of the resultant table contains a heading.
Examples: The following shows how you would use this in a report, with each calculation being a cell calculation with an Ident of MyTable. The first calculation initialises the table; the subsequent ones accumulate a count and a value.
myTable = CreateTable() myTable=TableAccumulate(MyTable, "A", 1, 3.5) myTable=TableAccumulate(MyTable, "B", 1, 4) myTable=TableAccumulate(MyTable, "A", 1, 2.5)
Resulting table is
Value | Value | |
A | 2 | 6 |
B | 1 | 4 |
Note: The simple form of tableAccumulate(tab) will take a tab and new line delimited text string and return it as a table. The first "column" in the text string will be the keys, and all other "columns" should be numeric.
See Also:
CreateTable: Create an empty accumulator table
Sort: Sort a delimited tabular string
TableAccumulateColumn: Accumulate data in one column for a key
TableFind: Look up a key in the table
TableGet: Extract data for a key or index found with TableFind
Transpose: Transpose a tabular delimited string