Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Aggregate Sum based on Condition in Kusto

I have the below query and I would like to find the total number of exams a student has taken in a school year as a new column called totalExamsTaken

StudentExam table has fields of studentID, examDesc, examGrade, schoolYear
StudentInfo table has fields of studentID, studentName, age, gender

StudentInfo
| lookup StudentExams on studentID
| project studentID, studentName, age, gender, examDesc, examGrade, schoolYear

In the end I would like to create a table that has columns of studentID, studentName, age, gender, schoolYear, totalExamsTaken.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

StudentID StudentName Age Gender SchoolYear TotalExamsTaken
 
0001       John Doe    15  Male     2019        13
0001       John Doe    15  Male     2018        19
0001       John Doe    15  Male     2017        15
0002       Jane Doe    16  Female   2019        13
0002       Jane Doe    16  Female   2018        19
0002       Jane Doe    16  Female   2017        12

Is this possible?

>Solution :

you could try something like this, using the lookup operator:

let examCountByStudentId = 
   StudentExams
   | summarize totalExamsTaken = count() by studentId, schoolYear
;
StudentInfo
| lookup examCountByStudentId on studentId
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading