# fieldvaluecount - script function

This script function returns the number of distinct values in a field. fieldname must be given as a string (for example a quoted literal).

Syntax:

fieldvaluecount(fieldname)

Example:

In this example the number of regions is counted and stored in the RegionCount variable. This value, 2 in this case, can then be used for further transformations where you need to know the number of existing regions.

`LOAD * INLINE
` `[ Region, Year, Month, Sales
` `South,	2014,	June,	645
` `North,	2014,	May,	245
` `North,	2014,	May,	347
` `North,	2014,	June,	127
` `South,	2013,	May, 367
` `South,	2013,	July,	221
];
` ` ` `
Let RegionCount = FieldValueCount('Region');`