从多列中选择数据并排序

时间:2021-02-12 13:56:26

标签: google-sheets

考虑以下表格 Products

    A        B      C      ...  Q
 1  product  type   origin      value
 2  apple    fruit  EN          0
 3  pear     fruit  US          5
 4  chicken  meat   DE          7
 5  beef     meat   DE          0
 6  cherry   fruit  US          3
 7  orange   fruit  DE          0
 8  peas     veg    US          2
 9  pork     meat   US          8
10  kale     veg    DE          4

我想编制一份所有产品的清单:

  • 有一个值 > 0
  • productoriginvalue
  • value 排序(从高到低)

如下(预期输出):

    A        B        C
 1  product  origin   value
 2  pork     US       8
 3  chicken  DE       7
 4  pear     US       5
 5  kale     DE       4
 6  cherry   US       3
 7  peas     US       2

我知道如何分别获取这 3 列:

=filter(Products!A$2:A, Products!Q$2:Q<>0)
=filter(Products!C$2:C, Products!Q$2:Q<>0)
=filter(Products!Q$2:Q, Products!Q$2:Q<>0)

但这不是有序的,我认为效率低下。

如何在 1 个公式中获取我需要的数据,并按照我需要的方式对其进行排序?

1 个答案:

答案 0 :(得分:2)

试试:

=QUERY(TRANSPOSE(QUERY(TRANSPOSE(A:C), 
 "where Col1 matches 'product|origin|value'", 0)), 
 "where Col3 > 0 order by Col3 desc", 0)

注意 matches 区分大小写

相关问题