title | description | ms.reviewer | ms.topic | ms.date |
---|---|---|---|---|
minif() (aggregation function) |
Learn how to use the minif() function to return the minimum value of an expression where the predicate evaluates to true. |
alexans |
reference |
03/12/2023 |
Returns the minimum of Expr in records for which Predicate evaluates to true
.
- Can be used only in context of aggregation inside summarize
See also - min() function, which returns the minimum value across the group without predicate expression.
minif
(
Expr,
Predicate)
[!INCLUDE syntax-conventions-note]
Name | Type | Required | Description |
---|---|---|---|
Expr | string |
✔️ | Expression that will be used for aggregation calculation. |
Predicate | string |
✔️ | Expression that will be used to filter rows. |
The minimum value of Expr in records for which Predicate evaluates to true
.
This example shows the minimum damage for events with casualties (Except 0)
[!div class="nextstepaction"] Run the query
StormEvents
| extend Damage=DamageCrops+DamageProperty, Deaths=DeathsDirect+DeathsIndirect
| summarize MinDamageWithCasualties=minif(Damage,(Deaths >0) and (Damage >0)) by State
| where MinDamageWithCasualties >0 and isnotnull(MinDamageWithCasualties)
Output
The results table shown includes only the first 10 rows.
State | MinDamageWithCasualties |
---|---|
TEXAS | 8000 |
KANSAS | 5000 |
IOWA | 45000 |
ILLINOIS | 100000 |
MISSOURI | 10000 |
GEORGIA | 500000 |
MINNESOTA | 200000 |
WISCONSIN | 10000 |
NEW YORK | 25000 |
NORTH CAROLINA | 15000 |
... | ... |