Skip to main content

FieldValueCount - script and chart function

FieldValueCount() is an integer function that finds the number of distinct values in a field.

Syntax:  

FieldValueCount(field_name)

Arguments:  

Argument Description
field_name Name of the field for which the value is required. Must be given as a string value. This means that the field name must be enclosed by single quotes.

Examples and results:  

The following example uses two fields: First name and Initials.

Examples Results

Chart function, as measure in a table

 

FieldValueCount('First name')

5 as Peter appears twice.

FieldValueCount('Initials')

6 as Initials only has distinct values.

Script function, as dimension in a table

 

Given the table Initials is loaded, as in the sample data:

John1:

Load FieldValueCount('First name') as MyFieldCount1

Resident Initials;

MyFieldCount1=5, because 'John' appears twice.

Given the table Initials is loaded, as in the sample data:

John1:

Load FieldValueCount('Initials') as MyInitialsCount1

Resident Initials;

MyFieldCount1=6, because 'Initials' only has distinct values.

Data used in example:

First name Initials
John JA
Sue SB
Mark MC
Peter PD
Jane JE
Peter PF

Data used in example:

Initials:

LOAD * inline [

"First name"|Initials|"Has cellphone"

John|JA|Yes

Sue|SB|Yes

Mark|MC |No

Peter|PD|No

Jane|JE|Yes

Peter|PF|Yes ] (delimiter is '|');

 

FieldCount1:

Load FieldValueCount('First name') as MyFieldCount1

Resident Initials;

 

FieldCount2:

Load FieldValueCount('Initials') as MyInitialsCount1

Resident Initials;

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!