How to count unique values in Excel with two conditions

前端 未结 3 1116
终归单人心
终归单人心 2020-12-04 02:50

I know there is already a question that has been answered about counting uniques with a condition (Count Unique values with a condition), but I want to know how to count uni

相关标签:
3条回答
  • 2020-12-04 02:59

    If you are using Excel 2013, there is a very simple approach w/o any formulas,

    Consolidate (excel feature under DATA), arrange in a way the City names are on left, and owner names next column to right, on top row put the labels of city and owner, then select the data and click both (header and left row) options, and for the operation from top of the dialogue choose count.

    You should have the report you are looking for.

    Note: You also might need to remove duplicates also you can do so based on two column conditions.

    0 讨论(0)
  • 2020-12-04 03:10

    The formula I suggested in the link is this

    =SUM(IF(FREQUENCY(IF(B2:B100=1,IF(A2:A100<>"",MATCH(A2:A100,A2:A100,0))),ROW(A2:A100)-ROW(A2)+1),1))

    that counts different values in A2:A100 if B2:B100 =1

    You can just add more IFs with more conditions, making sure you get the requisite number of parentheses in the correct locations, e.g. for the number of different owners by city and month try this version for March in Chicago

    =SUM(IF(FREQUENCY(IF(City="Chicago",IF(Month="March",IF(Owner<>"",MATCH(Owner,Owner,0)))),ROW(Owner)-MIN(ROW(Owner))+1),1))

    confirmed with CTRL+SHIFT+ENTER

    0 讨论(0)
  • 2020-12-04 03:19

    To add to Barry's answer: you don't have to nest the IF's as that gets messy quickly. You can simply multiply them together like this:

    IF((City="Chicago)*(Month="March"),...)
    

    It's much easier to add variables that way and keep track of parenthesis.

    0 讨论(0)
提交回复
热议问题