I'm trying to return a calculated array within Excel and was curious if it was possible.
Imagine a table with 3 fields, Fruit, Count, and Cost.
Fruit can appear multiple times. Count is equal to how many were purchased at any given time. Cost is equal to the unit cost per fruit.
If I were to want to know the average amount spent on a specific fruit, I have the formula {=AverageIf(A2:A10, "apples", count*cost)}. Unfortunately, this doesn't work. Sure I can create the formula myself in another row, but I'm trying to avoid this.
Does anyone have a solution?
You can use array formula
=AVERAGE(IF(A2:A10="Apples",B2:B10*C2:C10))
Entered with Ctrl + Shift + Enter
Or
=SUMPRODUCT(--(A2:A10="Apples"),B2:B10,C2:C10)/COUNTIF(A2:A10,"Apples")
This should be in a cell outside of the data area.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.