Excel Array Formula - #N/A error message on Average formula in some rows

narof

New Member
Joined
Mar 3, 2014
Messages
3
Hello,

Problem
I have an array formula that is returning a #N/A error on some categories only, that I don't know why.

Data Layout
My data is arranged like this;

StoreCategoryRevenueProfitMargin %SOHSpace m2GMROF
1
Pain$100$5050%$10002.5$20
2Pain$200$11557.5%$20003.0$38
3Pain$125$8064%$12502.2$36
4Pain$240$16066%$21503.0$53
5Pain$155$9561%$17502.8$34
Top 20Painxxxxxxxxxxxxx

<tbody>
</tbody>

Relevant information
  • 45 different categories (i.e. Pain, Cough etc..)
  • 40+ stores
  • Data is in a data table

Formula Outcome

I want to calculate the average of the Top 20% for each of the 45 categories (based on the stores with the highest GMROF for each category) and calculate this for each column: Revenue, Profit etc..

The slow way is to sort the pain category by GMROF, add a row, sort highest to lowest, write a average formula, then calculate the average of the Top 20% (8.4 stores, rounded to 8 stores) of the stores for each column.

Formula that works
{=AVERAGE(LOOKUP(RIGHT(LARGE(IF(Table2[CATEGORY]=$C1489,INT(Table2[GMROF])+ROW(Table2[GMROF])%%),ROW(INDIRECT("1:"&ROUND($L$1*COUNTIF(Table2[CATEGORY],$C1489),0)))),4)+0,ROW(Table2[CATEGORY]),Table2[Sales]))}


Formula returning a #N/A message
{=AVERAGE(LOOKUP(RIGHT(LARGE(IF(Table2[CATEGORY]=$C1490,INT(Table2[GMROF])+ROW(Table2[GMROF])%%),ROW(INDIRECT("1:"&ROUND($L$1*COUNTIF(Table2[CATEGORY],$C1490),0)))),4)+0,ROW(Table2[CATEGORY]),Table2[Sales]))}



Note: $L$1 = 20% (format in percentage)


Your assistance with this would be appreciated.

Cheers,

Narof
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Have you checked for trailing spaces?
It is kinda hard to diagnose the problem when there's no sample data and/or where the error occurs.
 
Upvote 0
Pivot table is an interesting idea, how would I return the average of the Top 20% based on GMROF in the Pivot Table?
 
Upvote 0
Create Pivot Table based on your data table
I assume you would have the following layout:
1) Category, Store in Row Label
2) Under Store label, you may apply filter: Top 20 --> Percent --> Based on the value you want
3) Set the Subtotal field to "Average"

Reminder: Use "Calculated Field" to show Margin instead of using the original data.

Hope it helps.


Pivot table is an interesting idea, how would I return the average of the Top 20% based on GMROF in the Pivot Table?
 
Upvote 0

Forum statistics

Threads
1,215,095
Messages
6,123,072
Members
449,093
Latest member
ripvw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top