let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Week #", type text}, {"Name", type text}, {"Unique IDs", type text}, {"LOB", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Rand", each Number.Random()),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Week #", "LOB"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"myList", each _, type table [#"Week #"=nullable text, Name=nullable text, Unique IDs=nullable text, LOB=nullable text, Index=number, Custom=number]}}),
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "SampleSize", each Number.RoundUp([Count]*0.25,0)),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom", each Table.FirstN(Table.Sort([myList], {"Rand", Order.Descending}),[SampleSize])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"myList"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Unique IDs"}, {"Unique IDs"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"SampleSize", Int64.Type}, {"Unique IDs", type text}})
in
#"Changed Type1"
Most of the steps you can follow in Query Editor, using "Applied Steps" pane.
Bookmarks