Search code examples
google-sheetsgoogle-sheets-formula

If value does not match in a cell then show it in another cell


I have a Google Sheet in which there are multiple codes. In one cell there is more than one code and in the other cell, the decision selected by the user is followed by the code.

Responses are fixed for the given codes.

I want the sheet to show if the codes selected by the users are wrong or correct in another column (if correct then leave the cell blank else to show the code selected by the user i.e the wrong code).

The conditions are:

Case 1: if the code displayed in column A is either "P" or "W" then the user's decision (column B) should be either "NO" or "YES" and the code (column C) selected by the user should be either "N" (if the decision is "NO") or "R" (if the decision is "YES") then in column D if the decision and code matches then leave the cell blank else to show the wrong code selected by the user.

Case 2: if the code displayed in column A does not have "P" or "W" code in the cell then the user's decision (column B) should be "NO" and the code (column C) selected by the user should be "IM" then in column D if the decision and code matches then leave the cell blank else to show the wrong code selected by the user. (P.S.: this condition can be created in another column).

enter image description here

I'm sharing a screenshot for reference. I searched for a formula but nothing worked.

Thank you.


Solution

  • You may try:

    =indeX(lambda(regX,if(len(A2:A),
                                   IF((regX*(B2:B="NO")*(C2:C="N"))+
                                      (regX*(B2:B="YES")*(C2:C="R"))+
                                      (not(regX)*(B2:B="NO")*(C2:C="IM")),,C2:C),))
          (regexmatch(A2:A,"\b(P|W)\b")))
    

    enter image description here