跳到主要內容

如何在Excel中基於多個條件計算唯一值?

本文,我將為您提供一些示例,供您根據工作表中的一個或多個條件來計算唯一值。 以下詳細步驟可能會對您有所幫助。

根據一個條件計算唯一值

根據兩個給定日期計算唯一值

根據兩個條件計算唯一值

根據三個條件計算唯一值


箭頭藍色右氣泡 根據一個條件計算唯一值

例如,我有以下數據范圍,現在,我要計算湯姆銷售的獨特產品。

具有多個條件的唯一文檔數1

請將此公式輸入到要獲取結果的空白單元格中,例如G2:

= SUM(IF(“ Tom” = $ C $ 2:$ C $ 20,1 /((COUNTIFS($ C $ 2:$ C $ 20,“ Tom”,$ A $ 2:$ A $ 20,$ A $ 2:$ A $ 20) ),0)),然後按 Shift + Ctrl + 輸入 鍵在一起以獲得正確的結果,請參見屏幕截圖:

具有多個條件的唯一文檔數2

備註:在以上公式中,“湯姆”是您要依據的名稱標準, C2:C20 是包含名稱標準的單元格 A2:A20 是您要計算唯一值的單元格。


箭頭藍色右氣泡 根據兩個給定日期計算唯一值

要計算兩個給定日期之間的唯一值,例如,我要計算日期範圍2016/9/1和2016/9/30之間的唯一乘積,請應用以下公式:

= SUM(IF($ D $ 2:$ D $ 20 <= DATE(2016,9,30)*($ D $ 2:$ D $ 20> = DATE(2016,9,1))),1 / COUNTIFS($ A $ 2 :$ A $ 20,$ A $ 2:$ A $ 20,$ D $ 2:$ D $ 20,“ <=”&DATE(2016,9,30),$ D $ 2:$ D $ 20,“> =”&DATE(2016, 9,1))),0),然後按 Shift + Ctrl + 輸入 鍵一起獲得唯一的結果,請參見屏幕截圖:

具有多個條件的唯一文檔數3

備註:在上式中,日期 2016,9,12016,9,30 是您要計算的開始日期和結束日期, D2:D20 單元格是否包含日期條件, A2:A20 是要從中計算唯一值的單元格。


箭頭藍色右氣泡 根據兩個條件計算唯一值

如果您要計算湯姆XNUMX月份銷售的獨特產品,以下公式可以為您提供幫助。

請將此公式輸入空白單元格以輸出結果,例如H2。

= SUM(IF((“ Tom” = $ C $ 2:$ C $ 20)*($ D $ 2:$ D $ 20 <= DATE(2016,9,30)*($ D $ 2:$ D $ 20> = DATE( 2016,9,1))),1 / COUNTIFS($ C $ 2:$ C $ 20,“ Tom”,$ A $ 2:$ A $ 20,$ A $ 2:$ A $ 20,$ D $ 2:$ D $ 20,“ <=“&DATE(2016,9,30),$ D $ 2:$ D $ 20,”> =“&DATE(2016,9,1))),0) 然後按 Shift + Ctrl + 輸入 鍵一起獲得唯一的結果,請參見屏幕截圖:

具有多個條件的唯一文檔數4

筆記:

1.在上式中,“湯姆”是名稱標準, 2016,9,12016,9,30 是您要計算的兩個日期, C2:C20 是單元格包含名稱標準,並且 D2:D20 單元格中是否包含日期, A2:A20 是您要計算唯一值的單元格範圍。

2.如果您需要使用“or”來計算唯一值的標準,例如,計算湯姆或在南部地區銷售的產品,請應用以下公式:

=SUM(--(FREQUENCY(IF(("Tom"=$C$2:$C$20)+("South"=$B$2:$B$20), COUNTIF($A$2:$A$20, "<"&$A$2:$A$20), ""), COUNTIF($A$2:$A$20, "<"&$A$2:$A$20))>0)),並記得按 Shift + Ctrl + 輸入 鍵一起獲得唯一的結果,請參見屏幕截圖:

具有多個條件的唯一文檔數5


箭頭藍色右氣泡 根據三個條件計算唯一值

要用三個標準來計算唯一產品,公式可能會更複雜。 假設計算出湯姆(Tom)在XNUMX月和北部地區銷售的獨特產品。 請這樣做:

將此公式輸入空白單元格以輸出結果I2,例如:

= SUM(IF((“ Tom” = $ C $ 2:$ C $ 20)*($ D $ 2:$ D $ 20 <= DATE(2016,9,30))*($ D $ 2:$ D $ 20> = DATE (2016,9,1))*(“北” = $ B $ 2:$ B $ 20),1 / COUNTIFS($ C $ 2:$ C $ 20,“ Tom”,$ A $ 2:$ A $ 20,$ A $ 2 :$ A $ 20,$ D $ 2:$ D $ 20,“ <=”&DATE(2016,9,30),$ D $ 2:$ D $ 20,“> =”&DATE(2016,9,1),$ B $ 2 :$ B $ 20,“ North”)),0),然後按 Shift + Ctrl + 輸入 鍵一起獲得唯一的結果,請參見屏幕截圖:

具有多個條件的唯一文檔數6

最佳辦公生產力工具

🤖 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 (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
For all the above formula an you suggest a non array formula as my data runs to 25000 rows. I need a free suggestions and not paid ones
This comment was minimized by the moderator on the site
Hi,
This is great - except I cant get it to work for what I require
I have two sheets - a Summary sheet, and another sheet containing data
The dates are dynamic - so you enter the date ranges in the Summary sheet in two cells (from B2 to D2)
When I replace DATE(2022,6,1) with B2 it comes back with "a value used in the formula is the wrong data type"
When I test with putting DATE(2022,6,1) and DATE (2022,6,30) in the from - to parts in the formula - I get 0 as the result - which is wrong.
Note: I'm in Ireland - so the date format here is dd.mm.yy - changing things doesn't fix - and adds confusion tbh
My formula is
=SUM(IF(Sheet4!$C$2:Sheet4!$C$65<=(D2)*(Sheet4!$C$2:Sheet4!$C$65>=(B2)), 1/COUNTIFS(Sheet4!$A$2:Sheet4!$A$65, Sheet4!$A$2:Sheet4!$A$65, Sheet4!$C$2:Sheet4!$C$65, "<="&D2,Sheet4!$C$2:Sheet4!$C$65, ">="&B2))),0)
Where Sheet4 contains the data, C2:C65 are cells with dates, A2:A65 are cells with project numbers - where there maybe duplicates
Any help - greatly appreciated,
Thanks
This comment was minimized by the moderator on the site
1 month2 brand name 3 executive wise4 mix party nameCount unique party name
This comment was minimized by the moderator on the site
Count Unique Values Based On four Criteria
This comment was minimized by the moderator on the site
I am trying to use this method to calculate unique customers for a particular product (where a customer may have bought multiple times, but I want unique customers). If I enter the formula but limit the range to a subset of just 5 rows that I know contain a duplicate customer, it works fine. But when I apply to the whole column, e.g. $D:$D, it calculates endlessly; if it finishes, it returns a wrong result. But now it's not even finishing and I have to end the Excel process. Is this just too costly in terms of CPU to apply to a large volume of data (e.g. 1500 rows)?
This comment was minimized by the moderator on the site
I ma getting value in point which is not possible So please help me Out

{=SUM(IF(("Regular"='Raw Data'!$G$5:$G$1785)*('Raw Data'!$D$5:$D$1785<=DATE(2019,6,30)*('Raw Data'!$D$5:$D$1785>=DATE(2019,6,1))),1/COUNTIFS('Raw Data'!$B$5:$B$1785,'Raw Data'!$B$5:$B$1785,'Raw Data'!$D$5:$D$1785,"<="&DATE(2019,6,30),'Raw Data'!$D$5:$D$1785,">="&DATE(2019,6,1))),0)}
This comment was minimized by the moderator on the site
my question.
I mean that filtered rows , and not count hidden rows.
This comment was minimized by the moderator on the site
"if count visible rows."
I mean filtered rows , and not count rows hidden.
This comment was minimized by the moderator on the site
Ffrom this article formula,
if count visible rows. how can add or edit formula?
This comment was minimized by the moderator on the site
The greater and less than date criteria is a distracting example of how to use the sumif array.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations