STDEVIF Function

Generates the standard deviation of values by group in a column that meet a specific condition.

NOTE: When added to a transform, this function is applied to the sample in the data grid. If you change your sample or run the job, the computed values for this function are updated. Transforms that change the number of rows in subsequent recipe steps do not affect the values computed for this step.

For more information on how the platform calculates standard deviation, see STDEV Function.

Basic Usage

aggregate value: STDEVIF(testScores, testScores > 0) group:studentId

Output: Generates a two-column table containing the unique values for studentId and the standard deviation of the testScores column for that studentId value when the testScores value is greater than 0.


aggregate value:STDEVIF(col_ref, test_expression) [group:group_col_ref]

ArgumentRequired?Data TypeDescription
col_refYstringReference to the column you wish to evaluate.
test_expressionYstringExpression that is evaluated. Must resolve to true or false

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

For more information on the group parameter, see Aggregate Transform.


Name of the column whose values you wish to use in the calculation. Column must be a numeric (Integer or Decimal) type.

Usage Notes:

Required?Data TypeExample Value
YesString that corresponds to the name of the columnmyValues


This parameter contains the expression to evaluate. This expression must resolve to a Boolean (true or false) value.

Usage Notes:

Required?Data TypeExample Value
YesString expression that evaluates to true or false(LastName == 'Mouse' && FirstName == 'Mickey')


Example - Conditional Calculation Functions

This example illustrates how you can use the following conditional calculation functions to analyze weather data:

  • AVERAGEIF - Average of a set of values by group that meet a specified condition. See AVERAGEIF Function.
  • MINIF - Minimum of a set of values by group that meet a specified condition. See MINIF Function.
  • MAXIF - Maximum of a set of values by group that meet a specified condition. See MAXIF Function.
  • VARIF - Variance of a set of values by group that meet a specified condition. See VARIF Function.
  • STDEVIF - Standard deviation of a set of values by group that meet a specified condition. See STDEVIF Function.


Here is some example weather data:

1/23/17Center Town0.319.45.3
1/23/17Magic Mountain0.000.07.3
1/24/17Center Town0.541.17.6
1/24/17Magic Mountain0.325.08.8
1/25/17Center Town0.833.35.1
1/25/17Magic Mountain0.59-1.76.4
1/26/17Center Town0.966.17.6
1/26/17Magic Mountain0.77-3.93.0
1/27/17Center Town1.3220.00.2
1/27/17Magic Mountain0.775.65.2
1/28/17Center Town0.145.04.9
1/28/17Magic Mountain1.501.10.4
1/29/17Center Town0.756.19.0
1/29/17Magic Mountain0.603.36.0


The following computes average temperature for rainy days by city:

derive value:AVERAGEIF(temp_C, rain_cm > 0) group:city as:'avgTempWRain'

The following computes maximum wind for sub-zero days by city:

derive value:MAXIF(wind_mph,temp_C < 0) group:city as:'maxWindSubZero'

This step calculates the minimum temp when the wind is less than 5 mph by city:

derive value:MINIF(temp_C,wind_mph<5) group:city as:'minTempWind5'

This step computes the variance in temperature for rainy days by city:

derive value:VARIF(temp_C,rain_cm >0) group:city as:'varTempWRain'

The following computes the standard deviation in rainfall for Center Town:

derive value:STDEVIF(rain_cm,city=='Center Town') as:'stDevRainCenterTown'

You can use the following transforms to format the generated output. Note the $col placeholder value for the multi-column transforms:

set col:stDevRainCenterTown,maxWindSubZero value:numformat($col,'##.##')

Since the following rely on data that has only one significant digit, you should format them differently:

set col:varTempWRain,avgTempWRain,minTempWind5 value:numformat($col,'##.#')


Here is some example weather data:

1/23/17Center Town0.319.45.37.3 532.60.37
1/23/17Magic Mountain0.
1/24/17Center Town0.541.17.67.3 532.60.37
1/24/17Magic Mountain0.325.
1/25/17Center Town0.833.35.17.3 532.60.37
1/25/17Magic Mountain0.59-
1/26/17Center Town0.966.17.67.3 532.60.37
1/26/17Magic Mountain0.77-
1/27/17Center Town1.3220.00.27.3 532.60.37
1/27/17Magic Mountain0.775.
1/28/17Center Town0. 532.60.37
1/28/17Magic Mountain1.501.
1/29/17Center Town0.756.19.07.3 532.60.37
1/29/17Magic Mountain0.603.

Send feedback about...

Google Cloud Dataprep Documentation