Skip to content
HPCCSystems Solutions Lab
HPCCSystems Solutions Lab

SAMPLE

SAMPLE function returns a sample set of dataset. Returned value is a dataset.

Syntax

SAMPLE(dataset, interval, [, which])
ValueDefinition
SAMPLERequired.
datasetInput dataset to process.
intervalThe intervals between records to return.
whichOptional. An integer specifying the ordinal number of the sample set to return. This is used to obtain multiple non-overlapping samples from the same recordset.

Demo Dataset

ColorID
Red100
Blue102
Black103
Yellow104
Orange105
White106
Green107
Purple108

Example


/*
REAL Example:
Collecting different sample sizes from the input dataset.
*/

Color_Layout := RECORD
    STRING   Color;
    INTEGER ID;
END;

Color_DS := DATASET([
                     {'Red', 100},    {'Blue', 102},   {'Black', 103},
                     {'Yellow', 104}, {'Orange', 105}, {'White', 106},
                     {'Green', 107},  {'Purple', 108}],
                     Color_Layout);

SampleOne := SAMPLE(Color_DS, 3);
OUTPUT(SampleOne, NAMED('SampleOne'));

SAMPLE(Color_DS, 2, 4);
Try Me