跳到主要內容

在輸入新數字時,如何平均一列的最後5個值?

在Excel中,您可以使用“平均值”功能快速計算一列中最後5個值的平均值,但是,您不時需要在原始數據後面輸入新的數字,並且您希望平均值會自動更改為輸入新數據。 也就是說,即使不時添加數字,您也希望平均值始終反映數據列表的最後5個數字。

列的最後5個值的平均值,作為使用公式輸入的新數字


箭頭藍色右氣泡 列的最後5個值的平均值,作為使用公式輸入的新數字

以下數組公式可以幫助您解決此問題,請執行以下操作:

在空白單元格中輸入以下公式:

=IF(COUNT(A:A),AVERAGE(INDEX(A:A,LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),MIN(5,COUNT(A1:A10000)))):A10000),"no data") (答: 是包含您使用的數據的列, A1:A10000 是動態範圍,您可以根據需要擴展它,並且數量 5 表示最後一個n值。),然後按 Ctrl + Shift + Enter 鍵一起獲得最後5個數字的平均值。 看截圖:

文檔平均最後 5-1

現在,當您在原始數據後面輸入新數字時,平均值也會隨之更改,請參見屏幕截圖:

文檔平均最後 5-2

備註:如果單元格列包含0個值,則要從最後0個數字中排除5個值,以上公式將不起作用,在這裡,我可以向您介紹另一個數組公式,以獲取最後5個非零值的平均值,請輸入以下公式:

=AVERAGE(SUBTOTAL(9,OFFSET(A1:A10000,LARGE(IF(A1:A10000>0,ROW(A1:A10000)-MIN(ROW(A1:A10000))),ROW(INDIRECT("1:5"))),0,1))),然後按 Ctrl + Shift + Enter 獲得所需結果的鍵,請參見屏幕截圖:

文檔平均最後 5-3


相關文章:

如何在Excel中每5行或每列平均一次?

如何在Excel中平均前3個值?

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour,

La formule ne fonctionnant pas chez moi, et ayant un fort besoin de l'avoir, j'ai creusé l'affaire.
Je ne comprenais pas pourquoi utiliser la fonction LARGE qui n'est là que si on cherche la plus grande valeur d'une colonne, qui n'est pas forcément dans les 5 derniers.

Donc, voici une formule simple (en français, mais vous trouverez facilement l'équivalent anglais) :
=MOYENNE(INDEX(A2:A1000;NB(A2:A1000)-5+1):A1000)
This comment was minimized by the moderator on the site
Hello Yves,

You can use the simple formula: =AVERAGE(OFFSET(A1,COUNT(A:A),0,-5)). Please have a try. Please see the attached picture.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
25% x (r) = (n), rounded up to the next whole number = (a) then the top (a) race points are averaged together to get the total race points (p) for the week.

Example: 25%x9 = 2.25 rounded up to 3. Top 3 races of the 9 races are averaged to get the total points for the week.

How do I create a formula in excel for this?
This comment was minimized by the moderator on the site
Hello, I would like average the lowest 10 values of the last 20 added to a set of data. After reading this one here and another one of your examples, I now know how to average the lowest 10 values of 20 and how to grab only the last 20 values for averaging, but I need to combine them so I only average the lowest 10 values of the last and or most resent 20 add to the set of data. Please let me know if you can help, thank you JT.
This comment was minimized by the moderator on the site
=IF(COUNT(A:A),AVERAGE(INDEX(A:A,LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),MIN(5,COUNT(A1:A10000)))):A10000),"no data")

Does not work for me.

Here is my version:
=IF(COUNT(C:C),AVERAGE(INDEX(C:C,LARGE(IF(ISNUMBER(C2:C10000),ROW(C2:C10000)),MIN(5,COUNT(C2:C10000))))):C10000)

The error I get is: Wrong data type.
This comment was minimized by the moderator on the site
Hello, Paul,
Do you press the Ctrl + Shift + Enter keys together after pasting the above formula?
Please try it.
This comment was minimized by the moderator on the site
I tried the formual =IF(COUNT(A:A),AVERAGE(INDEX(A:A,LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),MIN(5,COUNT(A1:A10000)))):A10000),"no data") then did COMMAND RETURN on my Mac and the formula worked but it didn't average the lowest 10 of the last 20 values correctly.I would like to average the lowest 8 values of of the last or most recent 20 values in a dynamic range as I enter a new value every day. Any help would be greatly appreciated!
This comment was minimized by the moderator on the site
Hello, Don,To solve your problem, please apply the below array formula:=AVERAGE(SMALL(IF((A1:A10000<>0)*(IF(ISNUMBER(A1:A10000),ROW(A1:A10000))=LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20})),A1:A10000),{1,2,3,4,5,6,7,8}))
After inserting the formula, please press 
This comment was minimized by the moderator on the site
Thank you! When I verify I do not get the correct value. My last 20 values are as follows: 0.0    0.2    8.9    2.9    8.1    8.1    8.1    5.3    8.1    0.4    6.6    -0.5    0.2    9.0    9.0    5.1    3.6    1.9    4.6    1.3Your array gives an average of 1.2 for the 8 lowest valuesMy average is 0.8 for the 8 lowest values.Not sure what went wrong?
This comment was minimized by the moderator on the site
I think it doesn't average zero. I tired <=> and that is not a solution.
This comment was minimized by the moderator on the site
Hi, Don,Yes, as you said, the formula exclude the 0s when averaging, if you want to average with 0s, please apply the below formula:=AVERAGE(SMALL(IF(ISNUMBER(A1:A10000)*(IF(ISNUMBER(A1:A10000),ROW(A1:A10000))=LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20})),A1:A10000),{1,2,3,4,5,6,7,8}))
Please remember to press Ctrl + Shift + Enter keys together.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations