Returning average value under specific conditions

bl3s

New Member
Joined
Jul 1, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a large spreadsheet with loads of data.
First, I'd like to give you a little idea what is the spreadsheet used for, so you get understanding what do I really need to calculate.
I do run injection moulder, making some product. Each 'female' produces some values in 'performance' columns, however values vary slightly depending on with which axis a female is paired to.
Axises generally can be grouped into 3 that perform similarly:
1)10, 20, 30, 150, 160, 170, 180
2)40,50,130,140
3)70,80,90,100,110,120

I need to calculate average value achieved by each female in 'performance' column but for specific groups of axis, in other words I need to calculate 3 different averages for the same 'female' and return these next to appropriate cell in 'inventory' tab. In the 'performance' column there are blank cells (these come from the past) and some text values (N/A, #N/A or SPR). Sheet is getting bigger as every new batch results get into it.

I tried to use index/match, if, average in various combinations, but I did not achieve any positive results.
If something sounds unclear, I will try to explain it better.
Many thanks for your help
 

Attachments

  • 123.png
    123.png
    85.1 KB · Views: 6
  • 234.png
    234.png
    62.2 KB · Views: 6

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi BL3s,

You could add a column to identify the group then just use AVERAGEIFS

Book1
EFGPQRAAABACAD
1AxisFemaleGroupPerformanceFemale10/20/30/150/160/170/18040/50/130/14070/80/90/100/110/120
2170SH211SH23.52.54.5
3140SH222SH3 7 
440SH223SH4  8
5120SH234
690SH235
710SH216
8130SH327
9110SH438
Sheet1
Cell Formulas
RangeFormula
AB2:AD4AB2=IFERROR(AVERAGEIFS($Q$2:$Q$9,$F$2:$F$9,$AA2,$G$2:$G$9,COLUMN()-COLUMNS($A2:$AA2)),"")
G2:G9G2=MATCH("*"&E2&"*",$AB$1:$AD$1,0)
 
Upvote 0
Hi Toadstool,

Many thanks for your attention.
I have tried to implement your solution, however when I extended the ranges, aferageifs simply does not show anything. Any idea?
 
Upvote 0
I have tried to implement your solution, however when I extended the ranges, aferageifs simply does not show anything. Any idea?
I suspect it is to do with using different columns or that you have some error values among your data.

Using Toadstool's layout & data, you could try this slightly simplified version of that formula & see if you can adapt that better. The 'COLUMNS' part of the formula should have an absolute column reference for the first instance of the first column that contains these formulas.

Note also that I have changed the column G formula. As it was, it could put rows into the incorrect group (eg change one of the column E values to 50 and you will see that the original column G formula returns Group 1 when it should be Group 2)

20 07 02.xlsm
EFGQRAAABACAD
1AxisFemaleGroupPerformanceFemale10/20/30/150/160/170/18040/50/130/14070/80/90/100/110/120
2170SH211SH23.52.54.5
3140SH222SH3 7 
440SH223SH4  8
5120SH234
690SH235
710SH216
8130SH327
9110SH438
Average 1
Cell Formulas
RangeFormula
AB2:AD4AB2=IFERROR(AVERAGEIFS($Q$2:$Q$9,$F$2:$F$9,$AA2,$G$2:$G$9,COLUMNS($AB2:AB2)),"")
G2:G9G2=MATCH("*/"&E2&"/*","/"&$AB$1:$AD$1&"/",0)



As an alternative, you could also try this formula that does not require the helper column.

20 07 02.xlsm
EFGQRAAABACAD
1AxisFemalePerformanceFemale10/20/30/150/160/170/18040/50/130/14070/80/90/100/110/120
2170SH21SH23.52.54.5
3140SH22SH3 7 
440SH23SH4  8
5120SH24
690SH25
710SH26
8130SH37
9110SH48
Average 2
Cell Formulas
RangeFormula
AB2:AD4AB2=IFERROR(SUMPRODUCT(--($F$2:$F$9=$AA2),--(ISNUMBER(SEARCH("/"&$E$2:$E$9&"/","/"&AB$1&"/"))),$Q$2:$Q$9)/SUMPRODUCT(--($F$2:$F$9=$AA2),--(ISNUMBER(SEARCH("/"&$E$2:$E$9&"/","/"&AB$1&"/")))),"")
 
Last edited:
Upvote 0
Hi,

@Peter_SSs I have encountered the same issue as with @Toadstool solution- no value returned.

As for grouping the axises I found the best result with index and match, see below
#Config builder STM- new1.xlsx
EFGHIJNOPQRSTUVWXYZAAABACAD
1AxisFemale InsertabcMale InsertpcdabcperformanceHit/MissMissHit %65.23%Female AvailableMale AvailableRow number10/20/30/150/160/170/18040/50/130/14060/70/80/90/100/110/120
2170SHT9/371SHT9FPM/26S9C-2.87/19SHT9MP/25-3.00-2.25170Miss37547042AvailableAvailable1110SHT9/37  
3170SHT9/401SHT9FPM/27S9C-2.87/28SHT9MP/26-3.50-2.25170HitAvailableAvailable2120SHT9/40   
4170SHT9/601SHT9FPM/28S9C-2.87/27SHT9MP/27-5.75-2.25170HitAvailableAvailable3130SHT9/103
510SHT9/1651SHT9FPM/29S9C-2.87/32SHT9MP/28-7.00-2.2510HitAvailableAvailable4240SHT9/104
6160SHT9/821SHT9FPM/30S9C-2.87/8SHT9MP/29-8.00-2.25160HitAvailableAvailable5250SHT9/105
7180SHT9/1821SHT9FPM/31S9C-2.87/30SHT9MP/30-8.50-2.25180HitAvailable#N/A6360SHT9/106
8150SHT9/1311SHT9FPM/32S9C-2.87/6SHT9MP/31#N/A#N/A#N/A#N/A#N/AAvailable7370SHT9/107
930SHT9/411SHT9FPM/33S9C-2.87/5SHT9MP/32-3.75-2.2530HitAvailableAvailable8380SHT9/108
1010SHT9/651SHT9FPM/34S9C-2.87/33SHT9MP/33-6.00-2.2510MissAvailableAvailable9390SHT9/109
1170SHT9/3093SHT9FPM/35S9C-2.12/36SHT9MP/34-7.50-2.2570HitAvailableAvailable103100SHT9/110
12180SHT9/3051SHT9FPM/36S9C-2.87/11SHT9MP/35-8.50-2.25180MissAvailable#N/A113110SHT9/111
13180SHT9/1831SHT9FPM/37S9C-2.87/13SHT9MP/36-8.50-2.25180HitAvailableAvailable123120SHT9/112
1430SHT9/1161SHT9FPM/26S9C-2.12/42SHT9MP/25-1.25-1.7530HitAvailableAvailable132130SHT9/113
15150SHT9/1031SHT9FPM/27S9C-2.12/30SHT9MP/26-2.25-1.75150HitAvailableAvailable142140SHT9/114
16170SHT9/391SHT9FPM/28S9C-2.12/33SHT9MP/27-3.50-1.75170HitAvailableAvailable151150SHT9/115
1740SHT9/442SHT9FPM/29S9C-1.87/1SHT9MP/28-3.75-1.7540HitAvailableAvailable161160SHT9/115
18140SHT9/1072SHT9FPM/30S9C-1.87/5SHT9MP/29-4.25-1.75140HitAvailableAvailable171170
1920SHT9/1201SHT9FPM/32S9C-2.12/40SHT9MP/31-1.75-1.7520Hit#N/AAvailable181180
STM data tab
Cell Formulas
RangeFormula
U1U1=T2/(T2+S2)
S2S2=COUNTIF(R2:R29996,"Miss")
T2T2=COUNTIF(R2:R30048,"HIT")
V2:V19V2=IF(INDEX('Insert Inventory'!A:A,(MATCH(F2,'Insert Inventory'!A:A,0)))>1,"Available","Not Available")
W2:W19W2=IF(INDEX('Insert Inventory'!K:K,(MATCH(I2,'Insert Inventory'!K:K,0)))>1,"Available","Not Available")
AB3:AD3,AC2:AD2AC2=IFERROR(AVERAGEIFS($Q$2:$Q$15009,$F$2:$F$15009,$AA2,$G$2:$G$15009,COLUMN()-COLUMNS($A2:$AA2)),"")
G2:G19G2=INDEX($Y$2:$Y$19,(MATCH(E:E,$Z$2:$Z$19,0)))
R2:R19R2=IF(AND(N2=D2,O2=C2,P2=E2),"Hit","Miss")
Named Ranges
NameRefers ToCells
'Insert Inventory'!_FilterDatabase='Insert Inventory'!$A$1:$R$498V2:V19
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N:PCell Valuecontains "SPR"textNO
V1:W12157Cell Valuenot containing "Available"textNO


in cell AA3 I left your formula with extended range. I hope I haven't done silly mistake when implementing it into the sheet.
 
Upvote 0
Hi,

@Peter_SSs I have encountered the same issue as with @Toadstool solution- no value returned.


in cell AA3 I left your formula with extended range. I hope I haven't done silly mistake when implementing it into the sheet.
That is not my formula in AA3. :)

Never-the-less, it appears to me that you are not getting any results because the AVERAGEIFS function in that formula is trying to average values in column Q. Since there are no values in column Q, that will result in a #DIV/0! error and hence the IFERROR wrapped around that function returns ""
 
Upvote 0
Hi @Peter_SSs

Thank you for your reply.
So apparently... Formulas work. I implemented them next to an old insert that no longer exists in my inventory due to being scrapped and there were no values in performance columns as I started collecting these data recently, hence no output in cells.
Thank you very much for your help!
 
Upvote 0
You're welcome. Glad you got it resolved.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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