简体   繁体   中英

Count the quantity of unique combinations in multiple columns in Excel

I need to have excel count the number of times number pairs occur in the same row regardless of their order. The following is what I'm look for. Column C will display the number of times A & B contain the same numbers, but not necessarily in the same columns (or order). Example below: 6 2 and 2 6 should be considered the same thing. Therefore the count in Column C should = 2 for both 6 2 and 2 6.

My Objective:

在此处输入图片说明

I tried the pivot table suggested at the following link and it successfully counted matching pairs, but for example 6 2 and 2 6 were not considered the same and the count was only 1 for each.

This simple pivot table solution almost works

Thank you! They all seem to work, but the easiest solution I found was here Quick to copy for large data

Use this array formula:

=SUM(COUNTIFS(A:A,A1:B1,B:B,TRANSPOSE(A1:B1)))

Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then excel will put {} around the formula.

在此处输入图片说明

使用您发布的SuperUser中解决方案 ,但使用:

=CONCATENATE(MAX(A2:B2),MIN(A2:B2))

I'm trying to think of a single - formula solution using COUNTIFS but can't find one at the moment so here's a two formula version.

In column D =IF(A2<B2,A2&", "&B2,B2&", "&A2)

In column C =COUNTIF(D:D, D2)

This creates a list in column D with the following logic;

If A < B then A goes first
If A > B then B goes first 
If A = B then B goes first but it doesn't really matter 

The list will be a set of strings which we then count.

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