简体   繁体   中英

Get unique count with two conditions in excel

How to get the count of unique keys with two conditions. Ex. Room C3 dated 2/1

Answer : 2 Since 123 and 124 is only the unique keys under C3 and 2/1

Keys Room. Dates
123  C1    2/1
125  C1    2/4
124  C3    2/2
123  C3    2/1
124  C3    2/1
123  C3    2/1

With Excel a unique count has always been a challenge. Approaches involve either long, convoluted array formulas (see here or this question ) or using Pivot tables as an intermediate step.

With the new Dynamic Array functions currently in preview for Office 365 Insider builds, this is a piece of cake, though.

This formula entered into just one single cell, no copying, will filter the data to return only the unique rows:

=UNIQUE(FILTER(B4:D9,(C4:C9=G2)*(D4:D9=G3),""))

The screenshot shows that the data automatically "spills" into the rows below.

在此处输入图片说明

If you are only interested in the final count, then filter only the first column and count the resulting data in one formula:

=COUNT(UNIQUE(FILTER(B4:B9,(C4:C9=G2)*(D4:D9=G3),"")))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM