使用 Google 表格查询功能对数据进行分组
Group data using Google Sheets Query function
我在 Google Sheet 中有以下数据:
I want to 运行 the Query function in another sheet so that when a date is selected the Query will return all attendees who attended an event on a single date in one像这样的专栏:
我的公式只有 return 每个日期下只有一名参加者,当时可能有 50 名员工参加一个活动。我想要一栏中的所有 50 个而不是 50 个单独的栏。
下面是 link 我的数据。 'Other Attendances' sheet 的单元格 D2 是我的查询函数。
我希望得到公式方面的帮助。
你可以这样做:
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'
order by C asc", 1), ";"), "^, ", )}))
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'"&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'"&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1), ";"), "^, ", )}))
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'"&
IF(B4<>"all", "and B = '"&B4&"'", )&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'"&
IF(B4<>"all", "and B = '"&B4&"'", )&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1), ";"), "^, ", )}))
我在 Google Sheet 中有以下数据:
I want to 运行 the Query function in another sheet so that when a date is selected the Query will return all attendees who attended an event on a single date in one像这样的专栏:
我的公式只有 return 每个日期下只有一名参加者,当时可能有 50 名员工参加一个活动。我想要一栏中的所有 50 个而不是 50 个单独的栏。
下面是 link 我的数据。 'Other Attendances' sheet 的单元格 D2 是我的查询函数。
我希望得到公式方面的帮助。
你可以这样做:
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'
order by C asc", 1), ";"), "^, ", )}))
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'"&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'
and B = '"&B4&"'"&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1), ";"), "^, ", )}))
=ARRAYFORMULA(TRANSPOSE({QUERY('Form Responses 4'!B:D,
"select B,C
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'"&
IF(B4<>"all", "and B = '"&B4&"'", )&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1),
REGEXREPLACE(SPLIT(QUERY('Form Responses 4'!B:D,
"select D
where C >= date '"&TEXT(B5, "yyyy-mm-dd")&"'
and C <= date '"&TEXT(B6, "yyyy-mm-dd")&"'"&
IF(B4<>"all", "and B = '"&B4&"'", )&
IF(B3<>"all", "and D contains '"&B3&"'", )&"
order by C asc", 1), ";"), "^, ", )}))