op.sample( aggColName as String, columndef as String, [options as String] ) as aggregatedef
This function randomly selects one non-null value of the column from the rows in the group or row set. The result is used for building the parameters used by the prototype.groupBy function.
Parameters | |
---|---|
aggColName | The name to be used for the value. |
columndef | The group or row set. |
options | The options can take a values key with a distinct value to average the distinct values of the column. |
const op = require('/MarkLogic/optic'); op.fromView('main', 'expenses') .groupBy('Category', op.sample("Sample Spent", "Amount")) .orderBy('Category') .result();
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.