KQL Mastery Path · by Kaushik Saha
KQL command reference
The 41 commands the course teaches, in one line each, grouped by the toolkit card that explains them. "Used in" links every card and mission whose queries use the command.
0.1 Look at the data
| Command | What it does | Shape | Used in |
|---|---|---|---|
take | Shows a few rows, any rows: a quick look | T | take 10 | 0.6 · 1.1 |
project | Keeps only the columns you name, in that order | T | project Col1, Col2 | 0.2 · 0.3 · 0.4 · 0.5 · 0.8 · 0.9 · 1.1 · 1.2 · 1.3 · 1.4 · 1.5 · 2.5 · 3.2 · 3.4 · 4.1 · 4.3 · 4.4 · 5.1 · 5.3 · 5.5 · 6.1 · 6.2 · 6.3 |
project-away | Drops the columns you name and keeps the rest | T | project-away Col1 | – |
project-rename | Renames a column | T | project-rename NewName = OldName | – |
distinct | Lists each different value (or combination) once | T | distinct Col | 0.3 · 0.7 · 0.8 · 4.1 · 6.5 |
0.2 Filter rows
| Command | What it does | Shape | Used in |
|---|---|---|---|
where | Keeps the rows where a condition is true | T | where Col == "value" | 0.3 · 0.4 · 0.5 · 0.6 · 0.7 · 0.8 · 0.9 · 1.2 · 1.3 · 1.4 · 1.5 · 2.1 · 2.2 · 2.3 · 2.4 · 2.5 · 3.2 · 3.3 · 3.4 · 3.5 · 4.1 · 4.2 · 4.3 · 4.4 · 4.5 · 5.1 · 5.2 · 5.3 · 5.4 · 5.5 · 6.1 · 6.2 · 6.3 · 6.4 · 6.5 |
== | Equals, exactly (case matters) | Col == "value" | 0.4 · 0.6 · 0.7 · 0.8 · 0.9 · 1.2 · 1.4 · 1.5 · 3.1 · 3.2 · 3.3 · 3.4 · 3.5 · 4.1 · 4.2 · 4.3 · 4.4 · 4.5 · 5.1 · 5.2 · 5.3 · 5.4 · 5.5 · 6.1 · 6.2 · 6.3 · 6.4 · 6.5 |
!= | Is not equal | Col != "value" | 0.6 · 0.8 · 1.2 · 1.3 · 1.5 · 2.1 · 2.2 · 2.3 · 2.4 · 2.5 · 3.1 · 3.4 |
=~ | Equals, ignoring upper and lower case | Col =~ "VALUE" | – |
and / or | Both conditions must be true / either one may be | A == 1 and B == 2 | 0.3 · 1.4 · 2.4 · 3.2 · 3.3 · 3.4 · 4.1 · 4.3 · 4.4 · 5.3 · 5.4 · 6.1 · 6.4 |
0.3 Match text
| Command | What it does | Shape | Used in |
|---|---|---|---|
has | Finds a whole word inside a value. Fast, and the one to reach for first | Col has "word" | 1.4 |
contains | Finds any piece of text, even inside a word. Slower | Col contains "text" | – |
startswith | The value begins with this text | Col startswith "text" | 3.3 |
in | The value is one of a list | Col in ("a", "b") | 5.2 · 6.3 |
in~ | One of a list, ignoring case | Col in~ ("a", "b") | – |
has_any | Has at least one of these words | Col has_any ("a", "b") | – |
0.4 Put rows in order
| Command | What it does | Shape | Used in |
|---|---|---|---|
sort by | Puts the rows in order: desc for newest or biggest first, asc for oldest or smallest | T | sort by Col desc | 0.5 · 0.6 · 0.8 · 0.9 · 1.4 · 2.1 · 2.2 · 2.4 · 3.1 · 3.3 · 4.1 · 5.1 · 5.2 · 5.3 · 6.1 · 6.3 |
top | Sorts and keeps the first N rows in one step | T | top 5 by Col desc | 1.3 · 3.2 |
0.5 Work with time
| Command | What it does | Shape | Used in |
|---|---|---|---|
ago | A moment in the past, counted back from now | TimeGenerated > ago(1h) | 2.4 · 3.4 · 6.4 |
now | The current time | now() | – |
between | Inside a range, both ends included | Col between (A .. B) | 5.1 · 5.3 |
bin | Rounds times down into buckets, so you can count per hour or per day | bin(TimeGenerated, 1h) | 2.4 |
0.6 Count and group
| Command | What it does | Shape | Used in |
|---|---|---|---|
count | How many rows. On its own as | count, or count() inside summarize | T | count | 0.2 · 0.3 · 0.5 · 0.7 · 0.8 · 0.9 · 2.1 · 2.2 · 2.3 · 2.4 · 2.5 · 3.4 · 4.2 · 4.5 · 5.4 · 6.1 |
summarize | Groups rows and works out one row per group | T | summarize count() by Col | 0.3 · 0.5 · 0.7 · 0.8 · 0.9 · 2.1 · 2.2 · 2.3 · 2.4 · 2.5 · 3.1 · 3.3 · 3.4 · 3.5 · 4.2 · 4.3 · 4.4 · 4.5 · 5.2 · 5.4 · 6.1 · 6.4 |
countif | Counts only the rows that match | countif(Col != "0") | 3.1 · 3.5 · 5.4 |
dcount | How many different values | dcount(Col) | 0.7 · 2.2 · 2.3 · 2.5 · 4.2 |
min / max | The smallest / largest value, such as the first and last time | min(TimeGenerated) | 3.4 · 4.3 · 5.4 · 6.1 · 6.4 |
arg_max | The whole row with the largest value, such as each user's latest sign-in | arg_max(TimeGenerated, *) by User | 3.3 · 4.4 |
make_set / make_list | Collects the values into a list: each once / all of them | make_set(Col) | 4.2 · 5.2 · 5.4 · 6.4 |
0.7 Add columns and reuse values
| Command | What it does | Shape | Used in |
|---|---|---|---|
extend | Adds a new column worked out from the others | T | extend New = Col1 + Col2 | 0.8 · 0.9 · 4.1 · 4.2 · 4.3 · 4.4 · 4.5 · 6.2 |
iff | Picks one of two values: if the condition is true, the first | iff(Col == "0", "yes", "no") | – |
tostring | Turns a value into text, often from a nested field | tostring(Col.field) | 0.9 · 4.1 · 4.2 · 4.5 · 5.3 · 5.5 · 6.2 · 6.3 |
let | Gives a value or a whole query a name, to use below | let Name = "value"; | 0.8 · 3.2 · 3.4 · 3.5 · 4.3 · 4.4 · 6.4 |
0.8 Combine tables
| Command | What it does | Shape | Used in |
|---|---|---|---|
union | Stacks the rows of two or more tables or queries | union TableA, TableB | 6.3 |
join | Puts rows side by side when a key matches | A | join kind=inner B on Key | 3.4 · 4.3 · 4.4 · 6.1 · 6.4 · 6.5 |
kind=inner | Keeps keys found on both sides | join kind=inner | 3.4 · 4.3 · 4.4 · 6.1 · 6.4 · 6.5 |
kind=leftouter | Keeps every left row, with blanks where the right has no match | join kind=leftouter | – |
kind=leftanti | Keeps left rows with no match on the right: "in A but not in B" | join kind=leftanti | – |
0.9 Open nested fields
| Command | What it does | Shape | Used in |
|---|---|---|---|
dot notation | Reads a field inside a dynamic (JSON) column | Col.field | 0.7 · 4.1 · 4.2 · 4.4 · 4.5 · 5.3 · 5.5 |
parse_json | Turns JSON stored as text into a dynamic value you can read | parse_json(Col) | 5.3 · 5.5 |
mv-expand | Turns a list into one row per item | T | mv-expand Item = ListCol | 5.3 · 5.5 |