VeriKQL by Kaushik Saha

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

CommandWhat it doesShapeUsed in
takeShows a few rows, any rows: a quick lookT | take 100.6 · 1.1
projectKeeps only the columns you name, in that orderT | project Col1, Col20.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-awayDrops the columns you name and keeps the restT | project-away Col1–
project-renameRenames a columnT | project-rename NewName = OldName–
distinctLists each different value (or combination) onceT | distinct Col0.3 · 0.7 · 0.8 · 4.1 · 6.5

0.2 Filter rows

CommandWhat it doesShapeUsed in
whereKeeps the rows where a condition is trueT | 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 equalCol != "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 caseCol =~ "VALUE"–
and / orBoth conditions must be true / either one may beA == 1 and B == 20.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

CommandWhat it doesShapeUsed in
hasFinds a whole word inside a value. Fast, and the one to reach for firstCol has "word"1.4
containsFinds any piece of text, even inside a word. SlowerCol contains "text"–
startswithThe value begins with this textCol startswith "text"3.3
inThe value is one of a listCol in ("a", "b")5.2 · 6.3
in~One of a list, ignoring caseCol in~ ("a", "b")–
has_anyHas at least one of these wordsCol has_any ("a", "b")–

0.4 Put rows in order

CommandWhat it doesShapeUsed in
sort byPuts the rows in order: desc for newest or biggest first, asc for oldest or smallestT | sort by Col desc0.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
topSorts and keeps the first N rows in one stepT | top 5 by Col desc1.3 · 3.2

0.5 Work with time

CommandWhat it doesShapeUsed in
agoA moment in the past, counted back from nowTimeGenerated > ago(1h)2.4 · 3.4 · 6.4
nowThe current timenow()–
betweenInside a range, both ends includedCol between (A .. B)5.1 · 5.3
binRounds times down into buckets, so you can count per hour or per daybin(TimeGenerated, 1h)2.4

0.6 Count and group

CommandWhat it doesShapeUsed in
countHow many rows. On its own as | count, or count() inside summarizeT | count0.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
summarizeGroups rows and works out one row per groupT | summarize count() by Col0.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
countifCounts only the rows that matchcountif(Col != "0")3.1 · 3.5 · 5.4
dcountHow many different valuesdcount(Col)0.7 · 2.2 · 2.3 · 2.5 · 4.2
min / maxThe smallest / largest value, such as the first and last timemin(TimeGenerated)3.4 · 4.3 · 5.4 · 6.1 · 6.4
arg_maxThe whole row with the largest value, such as each user's latest sign-inarg_max(TimeGenerated, *) by User3.3 · 4.4
make_set / make_listCollects the values into a list: each once / all of themmake_set(Col)4.2 · 5.2 · 5.4 · 6.4

0.7 Add columns and reuse values

CommandWhat it doesShapeUsed in
extendAdds a new column worked out from the othersT | extend New = Col1 + Col20.8 · 0.9 · 4.1 · 4.2 · 4.3 · 4.4 · 4.5 · 6.2
iffPicks one of two values: if the condition is true, the firstiff(Col == "0", "yes", "no")–
tostringTurns a value into text, often from a nested fieldtostring(Col.field)0.9 · 4.1 · 4.2 · 4.5 · 5.3 · 5.5 · 6.2 · 6.3
letGives a value or a whole query a name, to use belowlet Name = "value";0.8 · 3.2 · 3.4 · 3.5 · 4.3 · 4.4 · 6.4

0.8 Combine tables

CommandWhat it doesShapeUsed in
unionStacks the rows of two or more tables or queriesunion TableA, TableB6.3
joinPuts rows side by side when a key matchesA | join kind=inner B on Key3.4 · 4.3 · 4.4 · 6.1 · 6.4 · 6.5
kind=innerKeeps keys found on both sidesjoin kind=inner3.4 · 4.3 · 4.4 · 6.1 · 6.4 · 6.5
kind=leftouterKeeps every left row, with blanks where the right has no matchjoin kind=leftouter–
kind=leftantiKeeps left rows with no match on the right: "in A but not in B"join kind=leftanti–

0.9 Open nested fields

CommandWhat it doesShapeUsed in
dot notationReads a field inside a dynamic (JSON) columnCol.field0.7 · 4.1 · 4.2 · 4.4 · 4.5 · 5.3 · 5.5
parse_jsonTurns JSON stored as text into a dynamic value you can readparse_json(Col)5.3 · 5.5
mv-expandTurns a list into one row per itemT | mv-expand Item = ListCol5.3 · 5.5