CumMax
CumMax
calculates the cumulative maximum in an updateBy
table operation.
Syntax
CumMax(pairs...)
Parameters
Parameter | Type | Description |
---|---|---|
pairs | String... | The column(s) to be operated on. These can include expressions to rename the output columns (e.g., |
Returns
An UpdateByOperation
to be used in an updateBy
table operation.
Examples
The following example performs an updateBy
on the source
table using the CumMax
operation. No grouping columns are given. As a result, the cumulative maximum is calculated for all rows.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)")
result = source.updateBy(CumMax("MaxX = X"))
- source
- result
The following example builds on the previous example by specifying Letter
as the grouping column. Thus, the result
table has cumulative maximum calculated per unique letter in that column.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)")
result = source.updateBy(CumMax("MaxX = X"), "Letter")
- source
- result
The following example builds on the previous example by calculating the cumulative maximum for two columns using a single UpdateByOperation
.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)", "Y = randomInt(25, 50)")
result = source.updateBy(CumMax("MaxX = X", "MaxY = Y"), "Letter")
- source
- result
The following example builds on the previous example by specifying two key columns. Thus, each group is a unique combination of letter in the Letter
column and boolean in the Truth
column.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "Truth = randomBool()", "X = randomInt(0, 25)", "Y = randomInt(25, 50)")
result = source.updateBy(CumMax("MaxX = X", "MaxY = Y"), "Letter", "Truth")
- source
- result