let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Service", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"BDE_RISK_CATEGORY"}, {{"Count", each _, type table [#"Case ID "=number, Test Name=text, Date of Service=nullable date, BS_ORDERING_LAB=text, BDE_RISK_CATEGORY=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count], "Index",1,1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"BDE_RISK_CATEGORY", "Index"}, {"BDE_RISK_CATEGORY", "Index"}),
#"Grouped Rows1" = Table.Group(#"Expanded Custom", {"BDE_RISK_CATEGORY"}, {{"Max", each List.Max([Index]), type number}}),
#"Calculated Sum" = List.Sum(#"Grouped Rows1"[Max]),
#"Converted to Table" = #table(1, {{#"Calculated Sum"}}),
Custom1 = #"Grouped Rows1",
#"Added Custom1" = Table.AddColumn(Custom1, "Percent", each [Max]/#"Calculated Sum"),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Percent", Percentage.Type}})
in
#"Changed Type1"
Bookmarks