google-sheets - 如何根据Google表格中的标志列获取垂直数据并水平提取数据?
问题描述
我在 Google 表格中有以下数据格式:
我想根据 Ready 标志是 Y 还是 N,将 Quantity 列提取为 2 个单独的列。 Item Name 和 Size 将是 group By 列,以及 Ready 标志。以下是查询运行后我想要的数据格式:
还没有尝试过任何解决方案,因为我已经离开编程循环很长时间了,而且对 SQL 超级生疏。
解决方案
={"Item name", "Size", "Not ready", "Ready";
{QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col1, Col2", 0),
ARRAYFORMULA(ARRAY_CONSTRAIN(IFERROR(VLOOKUP(QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col1", 0)&
QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col2", 0),
QUERY(QUERY({A2:A&B2:B, C2:D},
"select *", 0),
"select Col1, Col2, Col3
where Col3='N'", 0), 2, 0), 0),
COUNTA(QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col1,Col2", 0))/2, 1)),
ARRAYFORMULA(ARRAY_CONSTRAIN(IFERROR(VLOOKUP(QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col1", 0)&
QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col2", 0),
QUERY(QUERY({A2:A&B2:B, C2:D},
"select *", 0),
"select Col1, Col2, Col3
where Col3='Y'", 0), 2, 0), 0),
COUNTA(QUERY(QUERY(QUERY(A2:D,
"select *", 0),
"select Col1, Col2, count(Col1)
where Col2 is not null
group by Col1, Col2
order by Col1 desc
label count(Col1)''", 0),
"select Col1,Col2", 0))/2, 1))}}
推荐阅读
- haskell - 在 do 表示法中使用 id
- r - 无法获取有关化学品饮用水标准的公共数据 - “无法加载 HTTP 资源”错误
- reactjs - 如何添加 ads.txt
- postgresql - 复制的复制
- java - DexArchiveMergerException 程序类型已存在:aaa
- amazon-web-services - 如何将多个 SSH 密钥应用于 AWS Lightsail 实例
- android - 无法将安全规则级联到子集合+允许创建不起作用
- javascript - 在传单侧边栏中切换 GeoJSON 层
- batch-file - 批处理文件 Scipt 在 if 语句中一次性执行所有指令
- javascript - 当 HTML 表单输入字段为空时,Google Apps 脚本中的错误