Level 0 · Your toolkit · Card 7 of 9 · by Kaushik Saha
Add columns and reuse values
Commands extend · iff · tostring · let
What these commands do
| Command | What it does | Shape |
|---|---|---|
extend | Adds a new column worked out from the others | T | extend New = Col1 + Col2 |
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) |
let | Gives a value or a whole query a name, to use below | let Name = "value"; |
See them work
extend and iff label each sign-in, then summarize counts the labels:
SigninLogs
| extend Outcome = iff(ResultType == "0", "success", "failure")
| summarize SignIns = count() by Outcome
Result on the sample · 2 rows
| Outcome | SignIns |
|---|---|
| failure | 25 |
| success | 116 |
tostring turns a value into text. You'll use it most on nested fields (card 0.9):
SigninLogs
| where UserPrincipalName == "alex.morgan@contoso.com"
| extend City = tostring(LocationDetails.city)
| distinct City
Result on the sample · 3 rows
| City |
|---|
| Amsterdam |
| Frankfurt am Main |
| Seattle |
let names a value once, so you change it in one place:
let Attacker = "203.0.113.45";
SigninLogs
| where IPAddress == Attacker
| summarize SignIns = count(), Users = dcount(UserPrincipalName)
Result on the sample · 1 row
| SignIns | Users |
|---|---|
| 11 | 1 |
Your turn
Name the attacker's address 203.0.113.45 with let, then list the apps it reached, each once.
Write it in the box below and check it. Then compare with one answer; others can be right too.
Show one answer
let Attacker = "203.0.113.45";
SigninLogs
| where IPAddress == Attacker
| distinct AppDisplayName
Result on the sample · 3 rows
| AppDisplayName |
|---|
| Office 365 Exchange Online |
| Microsoft Graph PowerShell |
| Azure Portal |
Check your own query
Write your query for the task above and check it against the real schema.
All data on this page is sample data, made up for this course. The IP addresses come from ranges reserved for documentation, and the people and the company are fictional.
Card by Kaushik Saha. Every query checked with Microsoft.Azure.Kusto.Language 12.4.1 against schema bundle 2026.10.29; every result computed on the course's sample with Kusto-Loco 1.4.9, an open-source KQL engine (credits). The story's clock reads 12:00 UTC on 10 June 2026.