Google 表格 - 我如何 return 按团队投票,按最受欢迎的投票排序?
Google Sheets - how can I return votes by team, sorted by the most popular votes?
我有一个 sheet 有参与者投票,每个参与者都在一个团队中。在第二个 sheet 中,我使用以下公式在每一行中创建每个团队的参与者投票子集(后跟选民姓名)。
=if($A:$A="","",arrayformula(textjoin(" ",true,sort(if(Score=10,"",if(Team=A2,REGEXREPLACE(Improve&" -
"&Detail&" ("&Name&")","/n"," "),"")),1,true))))
如何让结果按票数降序排列(首先显示最受欢迎的投票,然后显示第二受欢迎的票,依此类推?
如果有两个或更多主题的票数相同,使用选民姓名作为次要排序标准是有意义的。
这是 link 到 sheet with sample data。
我试过使用 SORT() 函数(第二个 sheet 中的 C 列),按字母顺序对结果进行排序,所以至少投票有效地分组了,但我需要显示最受欢迎的首先是问题,如 D 列所示。
E1 中的查询公式是作为 的答案提供的,我尝试操作该公式,但没有成功。
尝试:
=INDEX(SUBSTITUTE(SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({SORT(FILTER(
{data!B2:B&"×", COUNTIF(data!B2:B&data!D2:D, data!B2:B&data!D2:D), data!D2:D&"♥("&data!A2:A&")"}, data!C2:C<10), 1, 1, 2, 0, 3, 1),
SEQUENCE(ROWS(data!C2:C)-COUNTIFS(data!C2:C, 10))},
"select max(Col3) where not Col1 starts with '×' group by Col4 pivot Col1"),,9^9)), "×")), " ", CHAR(10)), "♥", " "),,2)
或与之前的:
={"Team", "Scores", "What needs improvement";
INDEX({UNIQUE(SORT(FILTER(data!B2:B, data!B2:B<>""))),
FLATTEN(SUBSTITUTE(TRIM(QUERY(REGEXREPLACE(SORT(QUERY(
QUERY({data!B2:B, TEXT(data!C2:C, "000000")&CHAR(13)&"("&data!A2:A&")"},
"select min(Col2) where Col1 is not null group by Col2 pivot Col1"),
"offset 1", 0), SEQUENCE(COUNTA(data!A2:A)), 0),
"^0{1,5}", ),,9^9)), " ", CHAR(10)))}),
INDEX(SUBSTITUTE(SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({SORT(FILTER(
{data!B2:B&"×", COUNTIF(data!B2:B&data!D2:D, data!B2:B&data!D2:D), data!D2:D&"♥("&data!A2:A&")"}, data!C2:C<10), 1, 1, 2, 0, 3, 1),
SEQUENCE(ROWS(data!C2:C)-COUNTIFS(data!C2:C, 10))},
"select max(Col3) where not Col1 starts with '×' group by Col4 pivot Col1"),,9^9)), "×")), " ", CHAR(10)), "♥", " "),,2)}
demo spreadsheet
我有一个 sheet 有参与者投票,每个参与者都在一个团队中。在第二个 sheet 中,我使用以下公式在每一行中创建每个团队的参与者投票子集(后跟选民姓名)。
=if($A:$A="","",arrayformula(textjoin(" ",true,sort(if(Score=10,"",if(Team=A2,REGEXREPLACE(Improve&" - "&Detail&" ("&Name&")","/n"," "),"")),1,true))))
如何让结果按票数降序排列(首先显示最受欢迎的投票,然后显示第二受欢迎的票,依此类推?
如果有两个或更多主题的票数相同,使用选民姓名作为次要排序标准是有意义的。
这是 link 到 sheet with sample data。
我试过使用 SORT() 函数(第二个 sheet 中的 C 列),按字母顺序对结果进行排序,所以至少投票有效地分组了,但我需要显示最受欢迎的首先是问题,如 D 列所示。
E1 中的查询公式是作为
尝试:
=INDEX(SUBSTITUTE(SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({SORT(FILTER(
{data!B2:B&"×", COUNTIF(data!B2:B&data!D2:D, data!B2:B&data!D2:D), data!D2:D&"♥("&data!A2:A&")"}, data!C2:C<10), 1, 1, 2, 0, 3, 1),
SEQUENCE(ROWS(data!C2:C)-COUNTIFS(data!C2:C, 10))},
"select max(Col3) where not Col1 starts with '×' group by Col4 pivot Col1"),,9^9)), "×")), " ", CHAR(10)), "♥", " "),,2)
或与之前的:
={"Team", "Scores", "What needs improvement";
INDEX({UNIQUE(SORT(FILTER(data!B2:B, data!B2:B<>""))),
FLATTEN(SUBSTITUTE(TRIM(QUERY(REGEXREPLACE(SORT(QUERY(
QUERY({data!B2:B, TEXT(data!C2:C, "000000")&CHAR(13)&"("&data!A2:A&")"},
"select min(Col2) where Col1 is not null group by Col2 pivot Col1"),
"offset 1", 0), SEQUENCE(COUNTA(data!A2:A)), 0),
"^0{1,5}", ),,9^9)), " ", CHAR(10)))}),
INDEX(SUBSTITUTE(SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({SORT(FILTER(
{data!B2:B&"×", COUNTIF(data!B2:B&data!D2:D, data!B2:B&data!D2:D), data!D2:D&"♥("&data!A2:A&")"}, data!C2:C<10), 1, 1, 2, 0, 3, 1),
SEQUENCE(ROWS(data!C2:C)-COUNTIFS(data!C2:C, 10))},
"select max(Col3) where not Col1 starts with '×' group by Col4 pivot Col1"),,9^9)), "×")), " ", CHAR(10)), "♥", " "),,2)}