Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Counts the rows in which predicate evaluates to true
.
Null values are ignored and don't factor into the calculation.
Note
This function is used in conjunction with the summarize operator.
countif
(
predicate)
Learn more about syntax conventions.
Name | Type | Required | Description |
---|---|---|---|
predicate | string |
✔️ | The expression used for aggregation calculation. The value can be any scalar expression with a return type of bool. |
Returns a count of rows in which predicate evaluates to true
.
This example shows the number of storms with damage to crops by state.
StormEvents
| summarize TotalCount=count(),TotalWithDamage=countif(DamageCrops >0) by State
The results table shown includes only the first 10 rows.
State | TotalCount | TotalWithDamage |
---|---|---|
TEXAS | 4701 | 72 |
KANSAS | 3166 | 70 |
IOWA | 2337 | 359 |
ILLINOIS | 2022 | 35 |
MISSOURI | 2016 | 78 |
GEORGIA | 1983 | 17 |
MINNESOTA | 1881 | 37 |
WISCONSIN | 1850 | 75 |
NEBRASKA | 1766 | 201 |
NEW YORK | 1750 | 1 |
... | ... | ... |
This example shows the number of names with more than 4 letters.
let T = datatable(name:string, day_of_birth:long)
[
"John", 9,
"Paul", 18,
"George", 25,
"Ringo", 7
];
T
| summarize countif(strlen(name) > 4)
Output
countif_ |
---|
2 |
count() function, which counts rows without predicate expression.