• 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.

How to compare alternate columns dynamically

sanalitics

New Member
Hello,

How do i atomate the below scenario with formula dynamically:
Here A1 is compared with A2 and A3 is compared with A4 and so on ... if all conditions matches I want the expected result to be True

Expected ResultA1A2A3A4A5A6
TRUE​
1​
1​
2​
2​
3​
3​
FALSE​
1​
1​
2​
2​
3​
4​

Thanks,
Sanal
 
If you have Excel 365, this formula is one possibility.
1708163687130.png
Code:
=BYROW(D2:K5;LAMBDA(row;LET(v_vals;WRAPROWS(row;2);
     NOT(ISNUMBER(XMATCH(FALSE;INDEX(v_vals;;1)=INDEX(v_vals;;2)))))))

Notice I'm on EU style, so where I have ";", you might have ",".
 
I was about to post and I discovered @GraH - Guido has already responded, with a very similar solution that I was about to propose.
The only tweak I'd add is to guarantee a FALSE if the range it acts upon does not have an even number of columns; that is to wrap the
Code:
INDEX(v_vals;;1)=INDEX(v_vals;;2)
part in an iferror:
Code:
IFERROR(INDEX(v_vals;;1)=INDEX(v_vals;;2);FALSE)
this makes sure that the #N/A that appears when the formula is acting upon an odd number of columns is converted to a FALSE.

See attached. Cell P2 is recommended(!):
Code:
=PairsMatch(A2:J13)


edit: here's another:
Code:
=BYROW(B2:K13,LAMBDA(a,NOT(ISNUMBER(XMATCH(FALSE,IFERROR(FILTER(a,ISODD(COLUMN(a)))=FILTER(a,ISEVEN(COLUMN(a))),FALSE))))))
 

Attachments

  • Chandoo56186.xlsx
    16.1 KB · Views: 5
Last edited:
The only tweak I'd add is to guarantee a FALSE if the range it acts upon does not have an even number of columns; that is to wrap the
Code:
INDEX(v_vals;;1)=INDEX(v_vals;;2)
part in an iferror:
Code:
IFERROR(INDEX(v_vals;;1)=INDEX(v_vals;;2);FALSE)
this makes sure that the #N/A that appears when the formula is acting upon an odd number of columns is converted to a FALSE.
Very nice addition by @p45cal .

From a private conversation on the topic... ;-)
1708177537635.png
 
Back
Top