Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何在Excel中基於多個條件對單元格求平均?

在Excel中,我們大多數人可能都熟悉COUNTIF和SUMIF函數,它們可以幫助我們根據條件對值進行計數或求和。 但是,您是否曾經嘗試過基於Excel中的一個或多個條件來計算平均值?

使用averageif函數基於一個條件對單元進行平均

使用Averageifs函數基於多個條件對單元進行平均


箭頭藍色右氣泡 使用averageif函數基於一個條件對單元進行平均

假設我具有以下數據范圍,A列是產品列表,B列是訂單,現在,我將對產品為KTE的訂單單元進行平均。

doc-avergae-with-criteria-1

請在您需要的單元格中輸入以下公式: =AVERAGEIF(A2:A19,D2,B2:B19)A2:A19 是包含條件的數據, B2:B19 指您想要平均的範圍, D2 是您要根據其取平均值的標準,然後按 Enter 獲得結果的關鍵,請參見屏幕截圖:

doc-avergae-with-criteria-2


箭頭藍色右氣泡 使用Averageifs函數基於多個條件對單元進行平均

如果您要使用多個條件來計算平均值,則 AVERAGEIFS 功能可能會幫助您。

Averageifs語法如下:

AVERAGEIFS(平均範圍,標準範圍1,標準1,標準範圍2,標準2…)

  • 平均範圍:是平均單元格範圍;
  • Criteria_range1, 條件範圍2,…是評估相關標準的範圍;
  • 準則1, 條件2,…是您所基於的條件。

以上面的數據為例,現在,我要平均KTE的訂單和大於500的訂單。請這樣做:

在空白單元格中輸入以下公式: =AVERAGEIFS(B2:B19,A2:A19,E1,B2:B19,">500")( A2:A19 是包含條件1的數據, B2:B19 指您要平均的範圍, E1> 500 是條件1和條件2),然後按 Enter 獲得所需結果的關鍵。 看截圖:

doc-avergae-with-criteria-3

備註: 如果您有兩個以上的條件,則只需要添加條件範圍和條件,如下所示: = AVERAGEIFS(C2:C19,A2:A19,F1,B2:B19,F2,C2:C19,“ <500”)A2:A19 F1 是第一個條件範圍和條件, B2:B19 F2 是第二個條件範圍和條件, C2:C19<500第三 標準範圍和標準, C2:C19 指範圍 想要取平均值),請參見屏幕截圖:

doc-avergae-with-criteria-4


相關文章:

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

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

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


最佳辦公效率工具

Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 超過300種強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

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

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 每天將您的工作效率提高50%,並減少數百次鼠標單擊!
officetab底部
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Jenin J · 9 months ago
    To get an average of data in a column with multiple criteria the following formulae may be used.

    Syntax = AVERAGEIFS (Range, Range 1, criteria 1, range 2, criteria 2)

    In this case, my requirement is to find the average of the data in a range of numbers, without considering '0 - Zero' & values greater that '3000'.

    Total data in the range is 31 nos ,

    And the formulae will be

    =AVERAGEIFS(G5:G35,G5:G35, "> 3000", G5:G35,"<>0")
  • To post as a guest, your comment is unpublished.
    La · 11 months ago
    I have 4 variables: 1st: Date of onset, 2nd: Date of termination, 3rd: Date of measurement, 4th: measurement. I want to calculate the average of the 4th variable between each period of onset-termination. How can i do it? I think its a bit tricky. Each date of onset has an counterpart date of termination. The same applies for the 3rd and 4th variable.
    How can i make this happen?
  • To post as a guest, your comment is unpublished.
    Mark Main · 11 months ago
    VBA code to average one or more ranges of nonzero numbers:


    Option Explicit
    Function avgNonZeros(ParamArray rangeList() As Variant) As Variant
    'Returns the average for all nonzeros of rangeList.
    'rangeList may be one or multiple ranges.
    Dim cell As Range
    Dim i As Long
    Dim totSum As Long
    Dim cnt As Long
    DoEvents 'allows calculations prior to performing
    avgNonZeros = 0 'default return
    For i = LBound(rangeList) To UBound(rangeList)
    For Each cell In rangeList(i)
    If cell <> 0 Then
    totSum = totSum + cell
    cnt = cnt + 1
    End If
    Next cell
    Next i
    If cnt <> 0 Then avgNonZeros = totSum / cnt
    End Function
  • To post as a guest, your comment is unpublished.
    Lutfur · 1 years ago
    Hi,
    I have 200 observations. I need to get an average of 21st to 40th observations. I am struggling to set an averageif formula. Any suggestion will be appreciated.
  • To post as a guest, your comment is unpublished.
    Crist · 1 years ago
    I have a similar problem like example #3, but the difference is that I need the average between two dates instead of for a single month. Any suggestion?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hello, Crist,

      To solve your problem, please apply the below formula:
      =AVERAGEIFS(C2:C15, A2:A15, F1, B2:B15, ">=" &F2, B2:B15, "<=" &G2, C2:C15, ">300")

      Please try, hope it can help you!
  • To post as a guest, your comment is unpublished.
    pablo · 2 years ago
    Hi there,


    My is Pablo and I would like to ask you about this situation. I have got a column with several values and some of them are zeros. As they are dB measurements this is the array formula I use to get the average: =10*LOG(AVERAGE(10^(C3:C66/10)))

    My problem is that I am trying to get with a formula that does not take in account the zeros.

    I have tried the next formula but it seems that does not work for my situation: =10*LOG(AVERAGEif(C3:C66,"<>0",[10^(C3:C66/10)]))

    It would be very apprecited if you could give me a hint to solve this problem.

    Thank you in advance,

    Pablo.
  • To post as a guest, your comment is unpublished.
    Stephanie · 3 years ago
    I want to take numbers in multiple columns and combine them into one average. I have three columns to average, I want two of the columns to count for 40% each and the remaining column to count for 20%. Is this possible? Thanks!
  • To post as a guest, your comment is unpublished.
    ch · 3 years ago
    I want to average cells is those cells are between a range.
    If A is between range 1 & range 2, average value in B. What formula would I use?
    Ex.
    A B Range 1 Range 2
    $78,093 651,462 55001 60000
    $76,968 636,679
    $76,946 1,682,295
    $73,909 142,277
    $73,567 624,257
    $71,505 492,828
    $67,772 351,316
    $63,786 458,169
    $63,263 157,665
    $58,427 180,498
    $56,693 187,028
    $56,510 73,339
    $56,129 80,832

    Thanks for any help.
  • To post as a guest, your comment is unpublished.
    Jackie · 4 years ago
    7
    $3.00
    20
    $40.00
    3
    $6.00
    0
    $-
    MY AVERAGE FOR CELL B3,B5,B7,B9 SHOULD BE 10
    MY COUNT FOR CELL B3,B5,B7,B9 SHOULD BE 3

    How do I get averages for specific cells excluding zero