maxif() (aggregation function)

Calculates the maximum value across the group for which Predicate evaluates to true.

Note

This function is used in conjunction with the summarize operator.

See also - max() function, which returns the maximum value across the group without predicate expression.

Syntax

maxif (Expr,Predicate)

Arguments

Name Type Required Description
Expr string Expression that will be used for aggregation calculation.
Predicate string Expression that will be used to filter rows.

Returns

Returns the maximum value of Expr across the group for which Predicate evaluates to true.

Example

This example shows the maximum damage for events with no casualties.

[Click to run query]

StormEvents
| extend Damage=DamageCrops+DamageProperty, Deaths=DeathsDirect+DeathsIndirect
| summarize MaxDamageNoCasualties=maxif(Damage,Deaths ==0) by State

Results

The results table shown includes only the first 10 rows.

State MaxDamageNoCasualties
TEXAS 25000000
KANSAS 37500000
IOWA 15000000
ILLINOIS 5000000
MISSOURI 500005000
GEORGIA 344000000
MINNESOTA 38390000
WISCONSIN 45000000
NEBRASKA 4000000
NEW YORK 26000000
... ...