Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »


Computes the variance among all values in a column. Input column can be of Integer or Decimal. If no numeric values are detected in the input column, the function returns 0

The variance of a set of values attempts to measure the spread in values around the mean. A variance of zero means that all values are the same, and a small variance means that the values are closely bunched together. A high value for variance indicates that the numbers are spread out widely. Variance is always a positive value.

Var(X) = [Sum ((X - mean(X))2)] / Count(X)

Variance comes in two flavors: population variance and sample variance.

  • Population variance computes the variance from all possible values.
  • Sample variance computes from a subset or sample of all values.
  • Since Trifacta® Self-Managed Enterprise Edition has access to all available values, the computation for population variance is used across the entire dataset.

The square root of variance is standard deviation, which is used to measure variance under the assumption of a bell curve distribution. See STDEV Function.

If a row contains a missing or null value, it is not factored into the calculation.

For a version of this function computed over a rolling window of rows, see ROLLINGVAR Function.

Basic Usage

pivot value:VAR(myRating) group:postal_code limit:1

Output: Generates a new table containing the unique values of the postal_code column and the variance of the group of values from the myRating column for the postal_code value. The limit parameter defines the maximum number of output columns.

Syntax and Arguments

pivot value:VAR(function_col_ref) [group:group_col_ref] [limit:limit_count]

ArgumentRequired?Data TypeDescription
function_col_refYstringName of column to which to apply the function

For more information on the group and limit parameters, see Pivot Transform.

For more information on syntax standards, see Language Documentation Syntax Notes.


Name of the column the values of which you want to calculate the variance. Column must contain Integer or Decimal values.

  • Literal values are not supported as inputs.
  • Multiple columns and wildcards are not supported.

Usage Notes:

Required?Data TypeExample Value
YesString (column reference)myValues


Tip: For additional examples, see Common Tasks.

This example illustrates how you can apply statistical functions to your dataset. Calculations include average (mean), max, min, standard deviation, and variance. 


Students took a test and recorded the following scores. You want to perform some statistical analysis on them:



You can use the following transforms to calculate the average (mean), minimum, and maximum scores:

derive type:single value:AVERAGE(Score) as:'avgScore'

derive type:single value:MIN(Score) as:'minScore'

derive type:single value:MAX(Score) as:'maxScore'

To apply statistical functions to your data, you can use the VAR and STDEV functions, which can be used as the basis for other statistical calculations. 

derive type:single value:VAR(Score)

derive type:single value:STDEV(Score)

For each score, you can now calculate the variation of each one from the average, using the following:

derive type:single value:((Score - avg_Score) / stdev_Score) as:'stDevs'

Now, you want to apply grades based on a formula:

Gradestandard deviations from avg (stDevs)
AstDevs > 1
BstDevs > 0.5
C-1 <= stDevs <= 0.5
DstDevs < -1
FstDevs < -2

You can build the following transform using the IF function to calculate grades.

derive type:single value:IF((stDevs > 1),'A',IF((stDevs < -2),'F',IF((stDevs < -1),'D',IF((stDevs > 0.5),'B','C'))))

For more information, see IF Function.

To clean up the content, you might want to apply some formatting to the score columns. The following reformats the stdev_Score and stDevs columns to display two decimal places:

set col:stdev_Score value:NUMFORMAT(stdev_Score, '##.00')

set col:stDevs value:NUMFORMAT(stDevs, '##.00')

derive type:single value:MODE(Score) as:'modeScore'





See Also for VAR Function:


  • No labels

This page has no comments.