Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Intertech Services AG
Yandex DataLens
  • Getting started
  • Tutorials
  • Concepts
  • Step-by-step guides
  • Access management
  • Pricing policy
  • Visualization reference
  • Function reference
    • All Functions
    • Aggregate functions
      • Overview
      • ALL_CONCAT
      • ANY
      • ARG_MAX
      • ARG_MIN
      • AVG
      • AVG_IF
      • COUNT
      • COUNTD
      • COUNTD_APPROX
      • COUNTD_IF
      • COUNT_IF
      • MAX
      • MEDIAN
      • MIN
      • QUANTILE
      • QUANTILE_APPROX
      • STDEV
      • STDEVP
      • SUM
      • SUM_IF
      • TOP_CONCAT
      • VAR
      • VARP
    • Array functions
    • Date/Time functions
    • Logical functions
    • Mathematical functions
    • Operators
    • String functions
    • Text markup functions
    • Time series functions
    • Type conversion functions
    • Window functions
    • Function Availability
  • Function tutorials
  • Courses
  • Troubleshooting
    • Questions and answers
    • DataLens errors
  1. Function reference
  2. Aggregate functions
  3. AVG_IF

AVG_IF

Written by
Yandex Cloud
,
improved by
amatol

Function AVG_IF is also found in the following categories: Window functions.

Syntax

Standard
Extended
AVG_IF( expression, condition )
AVG_IF( expression, condition
        [ FIXED ... | INCLUDE ... | EXCLUDE ... ]
        [ BEFORE FILTER BY ... ]
      )

More info:

  • FIXED, INCLUDE, EXCLUDE
  • BEFORE FILTER BY

Description

Returns the average of all values that meet the condition condition. If the values don't exist, it returns NULL. Applicable to numeric data types only.

Argument types:

  • expression — Fractional number | Integer
  • condition — Boolean

Return type: Fractional number

Example

AVG_IF([Profit], [Profit] > 5)

Data source support

ClickHouse 19.13, Microsoft SQL Server 2017 (14.0), MySQL 5.6, Oracle Database 12c (12.1), PostgreSQL 9.3, YDB.

Was the article helpful?

Language / Region
Yandex project
© 2023 Intertech Services AG