• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need Help Excluding Values From on Array

TGA123

New Member
Please see the attached excel file for clarification. I want to reference an existing array, and output the same array but excluding 2 particular values. Also, I only want one occurrence of these numbers to be removed from array. For example, in the example I have 116 listed as a value I want removed from the array, and 116 occurs twice. I only want one 116 to be removed not both.
 

Attachments

  • Help Me Figure This Out Please.xlsx
    10.1 KB · Views: 6
See attached cell H5 formula:
Code:
=RemoveSome(F5:F13,D5:D6)
RemoveSome is a named Lambda formula, which may be more complex than it needs to be, it's just the first thing that worked.
It removes the uppermost instance of the values, not that this makes any difference if the values in the Existing Data Set are sorted.
If a value is repeated in the values to be removed, still only one value is removed.
 

Attachments

  • Chandoo47920Help Me Figure This Out Please.xlsx
    11.3 KB · Views: 5
I decided I just had to use REDUCE as part of the solution to remove values!
Code:
= LET(
    reduced, REDUCE(existing, remove, zeroMatchλ),
    SORTBY(reduced,NOT(reduced))
  )
where
Code:
zeroMatchλ

= LAMBDA(data,value,
     LET(
        k, SEQUENCE(ROWS(data)),
        r, XLOOKUP(value, data, k, 0),
        IF(k <> r,data,0)
     )
  )
Mind you, I think removing the zeros in there entirety is more in keeping with dynamic array formulas
Code:
= LET(
   reduced, REDUCE(existing, remove, zeroMatchλ),
   FILTER(reduced,reduced))
 

Attachments

  • Help Me Figure This Out Reduce.xlsx
    13.3 KB · Views: 2
Back
Top