Skip to content
HPCCSystems Solutions Lab
HPCCSystems Solutions Lab

SET

SET converts values from a field/column in a dataset to a SET OF. SET can also be defined in brackets [ ] without need of a dataset.

Keep in mind that SET doesn’t order the list nor it will remove duplicates.

Syntax

attr_name := SET(dataset_name, field_name)
attr_name := SET[elem1, elem2, .... , elemN]
ValueDefinition
attr_nameThe name by which the function will be invoked.
SETRequired.
dataset_nameThe dataset to perform action on.
field_nameFields in the dataset.
[elem1, … , elemN]Values to create a set from.

Example


/*
SET Example:
Showing different examples  of how to define and use SET.
*/

// A set of strings
NameSet := ['alex', 'Joe', 'Sam']; 
OUTPUT(NameSet, NAMED('NameSet'));

// A set of integers
NumSet  := [56, -100, -96, 89, -100]; 
OUTPUT(NumSet, NAMED('NumSet'));

// A string definition can be in a set
StreetType := 'street';
StreetSet  := ['st', 'ct', 'dr', 'cir', streetType, 'blvd'];
OUTPUT(StreetSet, NAMED('StreetSet'));


CountRes := COUNT(1,2,3,3,3);
IntSet   := [9, 12, countRes];
OUTPUT(IntSet, NAMED('IntSet'));
Try Me

Covering dataset field to SET

Demo Dataset

CityStateCountyPopulation
Dauphin IslandALMobile1335
GuyARFaulkner778
El CentroCAImperial111425
IndioCARiverside417059
EnglewoodCOArapahoe6183
KeywestFLMonroe31401

Example


Pop_Layout := RECORD
STRING   City;
STRING   State;
STRING   County;
INTEGER  Population;
END;

Pop_DS := DATASET([
                {'Dauphin Island','AL','Mobile',1335},
                {'Guy','AR','Faulkner',778},
                {'El Centro','CA','Imperial',111425},
                {'Indio','CA','Riverside',417059},
                {'Englewood','CO','Arapahoe',6183},
                {'Keywest','FL','Monroe',31401}], 
                Pop_Layout);

// Converting a field to SET
CitySet := SET(Pop_DS, City);
OUTPUT(CitySet, NAMED('CitySet'));
Try Me