简体   繁体   English

谷歌表格查询 function

[英]Google Sheets QUERY function

I'm trying to create a query function that will average the numbers in columns B, C and D, based on what's in column f我正在尝试创建一个查询 function,它将根据 f 列中的内容平均列 B、C 和 D 中的数字

example:例子:

buckape 1000    10  1000    defense e6vowe0
aiden   500 9   900 defense e6vowe0
faxyst  400 8   800 defense e6vowe0
lumi    300 4   500 defense e6vowe0
refresh 200 2   400 defense e6vowe0
sahsook 100 1   200 defense e6vowe0
doltic  0   1   100 defense e6vowe0 

I'm able to, currently, make it average out the rows grouped by column F like so:目前,我能够将按 F 列分组的行平均化,如下所示:

=Query(A:F, "select F, avg(B), avg(C), avg(D) where F is not null and E='defense' group by F",-1)

which, in turn, results in my averages displayed by ID (which is good)反过来,这会导致我按 ID 显示平均值(这很好)

event ID    avg heal    avg kills   avg damage
e6vowe0     357.14      5.00        557.14
hfgk3og0    514.29      5.29        814.29

but, I'm struggling to get it to (in hopefully the same formula) also divide each original number (ie B2 / average of B based on F), then repeating the process for columns C and D as well.但是,我正在努力让它(希望使用相同的公式)也除以每个原始数字(即 B2 / 基于 F 的 B 的平均值),然后对列 C 和 D 重复该过程。

Hope this made sense, hope someone out here knows the query function better than I do.希望这是有道理的,希望这里有人比我更了解查询 function。 Thank you谢谢

try:尝试:

=ARRAYFORMULA(IF(A2:A="",,{A2:A, B2:D/QUERY(QUERY(A:F, 
 "select avg(B),avg(C),avg(D)
  where F is not null 
    and E='defense' 
  group by F", 0), "offset 1", 0)}))

update:更新:

=ARRAYFORMULA(IF(E2:E="defense", {A2:A, B2:D/
 IFNA(VLOOKUP(F2:F, QUERY(QUERY(A:F, 
 "select F,avg(B),avg(C),avg(D)
  where F is not null  
    and E='defense' 
  group by F", 0), "offset 1", 0), {2,3,4}, 0))}, ))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM