BSH
BSH

Reputation: 1

Google Sheets Pivot and Label using query

I have following data:

enter image description here

ITEM_NAME   ORDER_TYPE  NO_OF_ITEMS AVG_PRICE
BANANA      BUY         6           3
BANANA      BUY         6           3.5
APPLE       BUY         1           2
APPLE       SELL        1           2.5

I am writing following in my sheets

=QUERY(Sheet11!A:D,"SELECT A,SUM(C) ,AVG(D) WHERE A IS NOT NULL GROUP BY A PIVOT UPPER(B) LABEL A 'ITEM_NAME',SUM(C) 'TOTAL', AVG(D) 'PRICE_PER_ITEM'",1)

I would like to know if there is a way to label output as a result of PIVOT?

do not know how to proceed

Upvotes: 0

Views: 2253

Answers (1)

player0
player0

Reputation: 1

use:

=QUERY(QUERY(Sheet12!A:D,
 "select A,sum(C),avg(D) where A is not null group by A pivot upper(B)", 1), 
 "label Col2'Total_Buy',Col3'Total_Sell',Col4'Price_Per_Item',Col5'Price_Per_ Item_Sold'", 1)

enter image description here

Upvotes: 1

Related Questions