google sheets: use numbered column to list duplicates in specific order

rinkjames

New Member
Hello,

I have a sheet of fictional data here: duplicates. Below is a screenshot for convenience.

I'd like to list, in the `duplicate` column, duplicates of values in the `id` column, with one condition: that the corresponding row in the `complete` column must contain a `1`, not a `0`. Furthermore, I'd like to list duplicates in ascending order according to the `#` column, so that rows with lower numbers in the `#` column have their duplicate value listed before rows with higher numbers in the `#` column — even if I change the sort order of the columns using a data filter.

All values are hard-coded, except for my current working formula in the `duplicate` column; cell `F2` contains:

Excel Formula:
``=IF(SUMPRODUCT(\$D\$2:\$D\$21=D2,\$E\$2:\$E\$21=1)>1,E2*(SUMPRODUCT(\$D\$2:\$D2=D2,\$E\$2:\$E2=1)-1),0)``

To illustrate the problem, the columns in the above sheet are currently sorted in ascending order acording to column `#`, producing the following desired result in the `duplicates` column:

Rich (BB code):
``````#    name_first   name_last   id           complete   duplicate
4    Dominique    Jordan      kDgDIFL2St   0          0
7    Dominique    Jordan      kDgDIFL2St   1          0
15   Dominique    Jordan      kDgDIFL2St   1          1
19   Dominique    Jordan      kDgDIFL2St   1          2``````

However, if I use the data filter to change the sort order of the columns —e.g. the `#` column in descending order — then my current working formula produces the follwing undesired result in the `duplicates` column:

Rich (BB code):
``````#    name_first   name_last   id           complete   duplicate
19   Dominique    Jordan      kDgDIFL2St   1          0
15   Dominique    Jordan      kDgDIFL2St   1          1
7    Dominique    Jordan      kDgDIFL2St   1          2
4    Dominique    Jordan      kDgDIFL2St   0          0``````

As I hope the above illustrates, the specific rows marked as duplicates change when I change the sort order of the columns (e.g. blue from 2 to 0; yellow from 0 to 2). I'd like to adjust the formula in the `duplicate` column to avoid this and always produce the former of the two results above irrespective of the sort order of the columns. Any help would be appreciated.

Kind regards,
James

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the \$ sign).
Excel Formula:
``=IFNA(MATCH(A2,SORT(FILTER(\$A\$2:\$A\$21,(\$D\$2:\$D\$21=D2)*(\$E\$2:\$E\$21=1))),0)-1,0)``

Excel Formula:
``=IFNA(MATCH(A2,SORT(FILTER(\$A\$2:\$A\$21,(\$D\$2:\$D\$21=D2)*(\$E\$2:\$E\$21=1))),0)-1,0)``
Wonderful — thanks.

You're welcome & thanks for the feedback.

Replies
0
Views
294
Replies
2
Views
431
Replies
0
Views
376
Replies
1
Views
446
Replies
6
Views
709

1,217,323
Messages
6,135,899
Members
449,968
Latest member
Bpc1284

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back