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

how to make a new table from an existing table and add new column in spreadsheet

我想询问有关电子表格或 google-sheets 公式的问题。我有一个看起来像这样的数据:

   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

注:

  1. 我的数据只包含两种水果:苹果香蕉
  2. 2 媒体类型:BagCart
  3. 3 价格状态类型:付费信用免费

如您所见,该列与我在电子表格中赋予值 A-D 的列相同,而该行为 1-7, 我的计划是让床单看起来像这样:

UserId  Apple   Banana
3          1       0
7          1       1 
43         2       1

是否可以在电子表格中创建一个像这样的新 table?我尝试使用 VLOOKUP 但仍然无法实现,有人可以帮我解决这个问题吗?

尝试:

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