Distinct value in numbers column

Hi All,


I obviously tried to find the answer in discussions and google before submitting the question, but failed.



A
B Resolved-1 Resolved-2
123 AA 123 AA
124 AA 124 AA
321 ZZZ 321 ZZZ
123 AA
321 ZZZ
432 QQ 432 QQ



With COUNTIF you can get the number of duplicates in column A, but I'm not interested in the number of occurrences.

What I'm after is the distinct values in column A, copy that to the Resolved-1 row, then take the accompanying value of column B (many to one relationship between A and B) and place that in Resolved-2


I'm using Numbers v3.01.


Any help is greatly appreciated.


Hoot

Mac OS X (10.7)

Posted on Jan 7, 2014 11:42 AM

Reply
8 replies

Jan 24, 2017 3:06 PM in response to Hoot Posthorn

Hoot,


Here's a way that uses the Filter pane to give you a look only at a list of distinct entries. This may be better than creating a separate table listing of distince entries in some cases.


First, I add a column which is an index of distinct entries. This is where most approaches begin. The difference here is that I use a special text string to identify repeated instances of values from higher in the table. Here's a screen shot:

User uploaded file

The cells displaying "hide" are the repeats. The formula in my column B is:


=IF(B=1, COUNTIF(B$1:B2, 1), "hide")


It's simple and that's all you will have to do to the table before setting up the filter criteria.


The following screen shot shows what the table will look like after you activate the filter that hides the rows with repeated content by clicking on the Filters checkbox.


User uploaded file


I think it's a nice lean approach. I haven't been a big fan of the Filter pane operation, but I'm starting to see the benefits in cases like this.


Jerry

Jan 24, 2017 6:50 PM in response to Hoot Posthorn

Hi Leo,


It was a great surprise to see Jerry's post dated today (January 24, 2017) as he hasn't posted in this forum for the past 21 months! I suspect the date was changed when you marked the post Helpful today.


Jerry's table does include a column B, as the formula indicates, but that column is hidden.


Here's a solution (very similar to Waynes's) that gives the same results as shown by Jerry, but uses only column A, containing the items and column B. containing the index.

The filter rule is shown to the right of the table:

User uploaded file

Checking the "Filter" checkbox in the filter inspector shows only the rows with the first occurrence of each distinct value in column A.

User uploaded file

Formula in column B, entered in B2 and filled down to the end of the column:


IF(COUNTIF(A$1:A2,A2)=1,ROW()−1−COUNTIF(B$1:B1,"hide"),"hide")


Plain language translation:


If this is the only occurrence of the value in 'this row' of column A from row 1 to 'this row' of column A,

then

Get the number of 'this row', subtract 1 and subtract the number of occurrences of the word "hide" in cells above 'this row' in column B. Return that number to 'this cell'

else (ie. if there is more than one copy of the value)

Return the text "hide" to 'this cell'.


The number returned will be the number of distinct values in Column A from row 2 to the row containing the number. In this table, the largest number is the largest possible for the set of random two letter values constructed from X or Y in the first position and the letters A, B, C, D, E, F, or G in the second.


Regards,

Barry

Jan 24, 2017 3:27 PM in response to Jerrold Green1

Hi Jerry,

A belated answer, apologies for that..

I can see situations where this comes in handy, thanks for showing this.


Couple of questions though..

There is no B column in your screenshots, but your formula is referring to it. It's not hidden

Howcome the index is numbered consecutively even though there's cells which have their contents changed to Hide.


Cheers,

Leo

Jan 7, 2014 1:54 PM in response to Wayne Contello

Hi Wayne,


Thanks for your response, I believe you nailed it !


Rather than 'consume' your answer I've spent time getting my head around it.


If I understand it correctly the formula you created for the C2 field does:

(IF(ISBLANK(A2) - if true, then C2 = "", if false then (here we check if A2 is empty)

(IF(ISBLANK(A2) - if true then C2 = "" if false then (here we check if A2 is empty)

(IF

(IFERROR

(MATCH(A2,$A$1:A1,0) (here we see if we can match A2

...with the cell above it (A1))

.. and the 0 represents "Find value"

0) (value 0 belongs to the IFERROR statement.

No match yields 0)

>0 (So if we do have a match C2 will get value 0..

A2) ..and if we don't C2 will get the value of A2)


We can take this to town and have a ball.


The real magic is in the inner loop starting with (IF(IFERROR.., and more so in the absolute reference $A$1:A1

I looked up this notation in the reference, but could only find text about either $A$1 (absolute - not changing) and A1 (relative, changing when copying)


Looking at a test sheet, in C2 the formula refers to $A$1:A1 which is a range the match is held against

in C3 I see $A$1:A2

in C4 I see $A$1:A3

..

So in each next row the list against which the MATCH is working, is expanded by one. Nice !


The remaining question if I may:

Why twice the (if(isblank(a2) sequence ?


Thanks,

Hoot

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Distinct value in numbers column

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.