[英]Excel Count Unique Values From SUMPRODUCT
I have a sheet that is supposed to count the number of unique reservations an agent has done. 我有一张工作表,该工作表应该计算代理商已完成的唯一保留次数。 It currently counts duplicates though and I need to only count unique ones. 尽管它目前计算重复项,但我只需要计算唯一的重复项。
Here is the formula being used in the sheet: 这是工作表中使用的公式:
=SUMPRODUCT((Table_Query_from_db[client_code]=$B7)*(Table_Query_from_db[created_date_time]>=D$1)*(Table_Query_from_db[created_date_time]<D$1+1))
This counts the number of lines/records that show up for a specific person ( $B7
) for a specific date ( D$1
). 这将对特定日期( D$1
)针对特定人员( $B7
)出现的行/记录数进行计数。
Here is the sample of the sheet: 这是工作表示例:
As you can see B7
contains the agents number and D1
contains the date. 如您所见, B7
包含代理商编号, D1
包含日期。
Here is the dataset for that specific agent on that specific date: 这是该特定代理在该特定日期的数据集:
There is indeed 5 reservations - but only 3 unique ones. 确实有5个预订-但只有3个独特的预订。
How do I go about getting D7
in the first picture to come out as 3 instead of 5? 如何使第一张照片中的D7
变成3而不是5?
Use this array formula: 使用此数组公式:
=SUM(IF((Table_Query_from_db[client_code]=$B7)*(Table_Query_from_db[created_date_time]>=D$1)*(Table_Query_from_db[created_date_time]<D$1+1),1/COUNTIFS(Table_Query_from_db[reservation_number],Table_Query_from_db[reservation_number],Table_Query_from_db[client_code],$B7,Table_Query_from_db[created_date_time],">=" & D$1,Table_Query_from_db[created_date_time],"<" & D$1+1)))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. 作为数组公式,退出编辑模式时必须使用Ctrl-Shift-Enter而不是Enter进行确认。 If done correctly then Excel will put {}
around the formula. 如果操作正确,则Excel会将{}
放在公式周围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.