try:
=ARRAYFORMULA(TRANSPOSE(SORT(TRANSPOSE(QUERY('Raw Run Data'!A:O,
"select F,G,max(J)
where G ='5K'
and M = 7
and F matches '"&TEXTJOIN("|", 1, '180Day Runners'!A4:A)&"|1'
group by F,G pivot O", 1)), 1, 0)))
(не проверено, поскольку ваш лист не может быть скопирован)
или, возможно:
=ARRAYFORMULA(TRANSPOSE(SORT(TRANSPOSE(QUERY(TO_TEXT('Raw Run Data'!A:O),
"select Col6,Col7,max(Col10)
where Col7 ='5K'
and Col13 = '7'
and Col6 matches '"&TEXTJOIN("|", 1, '180Day Runners'!A4:A)&"|1'
group by Col6,Col7 pivot Col15", 1)), 1, 0)))