stacked100 with extend
stacked100 with extend
The `pivot` operator in Kusto does not work the way SQL pivoting
does. Instead, we need to **use `summarize` with `extend` or `make-series` to
reshape the data manually.**
Here’s the **correct Kusto Query Language (KQL) approach** to generate a **stacked
100% bar chart** for students' passed and failed exam counts:
---
StudentExams
| summarize Passed = sumif(ExamCount, ExamStatus == "Passed"),
Failed = sumif(ExamCount, ExamStatus == "Failed")
by StudentId
| extend Passed = coalesce(Passed, 0), Failed = coalesce(Failed, 0) // Handle
missing values
| extend TotalExams = Passed + Failed
| extend PassedPct = todouble(Passed) / TotalExams * 100,
FailedPct = todouble(Failed) / TotalExams * 100
| project StudentId, PassedPct, FailedPct
| render barchart kind=stacked100
```
---
---
Would you like to customize it further, maybe adding a date filter or dynamic
parameters? 😊