Forum Discussion

syasmin25's avatar
syasmin25
Helper V
6 years ago
Solved

Counting Core Courses

I have an issue and am having trouble wrapping my head around it. I am trying to count students absent in English and Math classes. The issue here is the database places students absent per period on...
  • AlB's avatar
    AlB
    6 years ago

    Hi syasmin25 

    If you want to do it in M/ Power query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZA/C4MwEMW/SsnskH8X4+hQ6GAnu4lDCFKk0i76/XsXY4waOLjH4+X9uK5jggtWMJp7U9MmuWF9QYZESfOsX4/V0dHRKFUWgS0CKMls/Th8/YBbaSseTDAGJaSUVBqCoSQlzF4E+OJ/4oKQw+UIG9sKFxh+fnTTrZ0Xf4XcOTLAI8YJsEqJxAfGxq7GTS4vsVDGq36Wd4r0fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Period = _t, Subject = _t, School_ID = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Period", Int64.Type}, {"Subject", type text}, {"School_ID", Int64.Type}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Subject] = "ELA" or [Subject] = "MATH")),
        #"Grouped Rows" = Table.Group(#"Filtered Rows", {"School_ID", "ID"}, {{"NumSubjectsInAbsence", each Table.RowCount(_), type number}}),
        #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"School_ID"}, {{"NumStudents", each List.Count(List.Select([NumSubjectsInAbsence],each _=2))}})
    in
        #"Grouped Rows1"

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers