let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"Driver Name", "Driver ID", "Bus Number", "Bus Capacity"}, "Attribute", "Value"),
#"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Columns", "Attribute", "Attribute - Copy"),
#"Replaced Value" = Table.ReplaceValue(#"Duplicated Column"," Students","",Replacer.ReplaceText,{"Attribute - Copy"}),
#"Renamed Columns" = Table.RenameColumns(#"Replaced Value",{{"Attribute - Copy", "St_Types"}}),
#"Grouped Rows" = Table.Group(#"Renamed Columns", {"Driver ID", "St_Types"}, {{"Gr", each if Table.RowCount(Table.FillDown(Table.AddColumn(_, "Fill_Down", each if Value.Is([Value], type number) then null else [Value]),{"Fill_Down"}))=2 then Table.RemoveFirstN(Table.FillDown(Table.AddColumn(_, "Fill_Down", each if Value.Is([Value], type number) then null else [Value]),{"Fill_Down"}),1) else Table.FillDown(Table.AddColumn(_, "Fill_Down", each if Value.Is([Value], type number) then null else [Value]),{"Fill_Down"}) , type table}}),
#"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Driver ID"}),
#"Expanded Gr" = Table.ExpandTableColumn(#"Removed Columns", "Gr", {"Attribute", "Bus Capacity", "Bus Number", "Driver ID", "Driver Name", "Fill_Down", "St_Types", "Value"}, {"Attribute", "Bus Capacity", "Bus Number", "Driver ID", "Driver Name", "Fill_Down", "St_Types.1", "Value"}),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Gr",{"St_Types.1"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Columns1",{"Driver Name", "Driver ID", "Bus Number", "Bus Capacity", "St_Types", "Fill_Down", "Value"}),
#"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Value", Int64.Type}}),
#"Replaced Errors" = Table.ReplaceErrorValues(#"Changed Type", {{"Value", null}}),
Finish = Table.RenameColumns(#"Replaced Errors",{{"St_Types", "Student_Type"}, {"Fill_Down", "Student_Name"}, {"Value", "Total_Student"}})
in
Finish