average all but last entry

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
684
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Need to average all entries but the LAST one.
Use Test in C30 & C31.
Thank you

The Whole Enchilada.xlsm
ABC
3SectorG/L %Date
4Tech 3X2.65%1/5/22
5Tech 3X-39.56%2/1/22
6Tech 3X-49.60%3/1/22
7Tech 3X-47.73%4/8/22
8Tech 3X-73.16%5/24/22
9Tech 3X-65.51%6/1/22
10Tech 3X-5.93%8/19/22
11Tech 3X-21.27%
12Finance 3x30.29%10/28/22
13Tech 3X-1.87%
14Finance 3x9.01%3/12/23
15Tech 3X33.60%
16Finance 3x-0.12%4/1/23
17Tech 3X31.58%
18Finance 3x-0.64%5/6/23
19Tech 3X70.14%
20Finance 3x5.54%6/14/23
21Tech 3X94.11%
22Finance 3x10.11%7/1/23
23Tech 3X100.04%
24Finance 3x14.91%
25TSLA 1.5x5.19%7/17/23
26Tech 3X99.60%
27Finance 3x24.99%7/23/23
28
29Test
30Tech 3x8.47%
31Finance 3x11.76%
Sector Perform-ALL
Cell Formulas
RangeFormula
C30C30=AVERAGEIFS(B4:B27,A4:A27,B30)
C31C31=AVERAGEIFS(B4:B27,A4:A27,B31)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
With Power Query aka Get and Transform Data and found on the Data Tab

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Sector"}, {{"Average", each List.Average([#"G/L %"]), type number}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Grouped Rows",{{"Average", Percentage.Type}})
in
    #"Changed Type"

SectorAverage
Tech 3X0.08472926
Finance 3x0.117617769
TSLA 1.5x0.051912568
 
Upvote 0
With Power Query aka Get and Transform Data and found on the Data Tab

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Sector"}, {{"Average", each List.Average([#"G/L %"]), type number}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Grouped Rows",{{"Average", Percentage.Type}})
in
    #"Changed Type"

SectorAverage
Tech 3X0.08472926
Finance 3x0.117617769
TSLA 1.5x0.051912568
not interested in Power Query, looking for a formula. Your results are giving me the same results as the formulas im using now.
i want to calculate the average MINUS the last entry (ie Tech 3X will calculate the average WITHOUT using row 26 in the equation (its the last entry).
 
Upvote 0
Try this formula in cell C30 and copy down to C31:
Excel Formula:
=(SUMIFS($B$4:$B$27,$A$4:$A$27,B30)-LOOKUP(2,1/($A$4:$A$27=B30),$B$4:$B$27))/(COUNTIFS($A$4:$A$27,B30)-1)
 
Upvote 0
Solution
Try this formula in cell C30 and copy down to C31:
Excel Formula:
=(SUMIFS($B$4:$B$27,$A$4:$A$27,B30)-LOOKUP(2,1/($A$4:$A$27=B30),$B$4:$B$27))/(COUNTIFS($A$4:$A$27,B30)-1)
Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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