Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 如何从现有表创建新表并在电子表格中添加新列_Google Sheets_Pivot_Google Sheets Formula_Google Sheets Query_Google Query Language - Fatal编程技术网

Google sheets 如何从现有表创建新表并在电子表格中添加新列

Google sheets 如何从现有表创建新表并在电子表格中添加新列,google-sheets,pivot,google-sheets-formula,google-sheets-query,google-query-language,Google Sheets,Pivot,Google Sheets Formula,Google Sheets Query,Google Query Language,我想询问有关电子表格或谷歌表格的公式。我的数据如下所示: A B C D ------------------------------------------------ 1 | UserId fruitType media PriceStatus 2 | 3 Apple Bag Paid 3 | 7 Banana Bag Paid 4 | 7

我想询问有关电子表格或谷歌表格的公式。我的数据如下所示:

   A       B           C          D
   ------------------------------------------------
1 | UserId  fruitType   media     PriceStatus
2 | 3       Apple       Bag       Paid
3 | 7       Banana      Bag       Paid
4 | 7       Apple       Bag       Paid
5 | 43      Banana      Bag       Paid
6 | 43      Apple       Bag       FREE
7 | 43      Apple       Cart      Credit
UserId  Apple   Banana
3          1       0
7          1       1 
43         2       1
注:

  • 我的数据只包括两种水果:苹果香蕉
  • 2种媒体类型:购物袋和购物车
  • 3种价格状态:已付信用免费
  • 正如您所看到的,该列与我在电子表格中给出的值A-D相同,该行为1-7,我的计划是使这些表看起来像这样:

       A       B           C          D
       ------------------------------------------------
    1 | UserId  fruitType   media     PriceStatus
    2 | 3       Apple       Bag       Paid
    3 | 7       Banana      Bag       Paid
    4 | 7       Apple       Bag       Paid
    5 | 43      Banana      Bag       Paid
    6 | 43      Apple       Bag       FREE
    7 | 43      Apple       Cart      Credit
    
    UserId  Apple   Banana
    3          1       0
    7          1       1 
    43         2       1
    
    有可能在电子表格中创建这样的新表格吗?我尝试使用了
    VLOOKUP
    ,但仍然无法实现,有人能帮我吗?

    试试:

    =QUERY(A1:D, "select A,count(A) where A is not null group by A pivot B", 1)
    

    哇,谢谢你。我试了一下,效果很好,但我能再问你一个问题吗?我们能给它零吗?因此,创建条件if语句更容易。当然,您可以这样做:
    =ARRAYFORMULA(IFERROR(查询(A1:D,“选择a,计数(a),其中a通过轴B不是空组”,1)*1,查询(A1:D,“选择a,计数(a),其中a通过轴B不是空组”,1))