Forum Discussion
Help with Formula
Peter_Browning It looks like there's a typo in either your sample data or the expected results that could use some clarification. Regarding reference 11302, type "Salary", you're showing code "FR19511107" in the top table, but "FR19611109" in the expected results table. I'm assuming the typo is in the top table, which should be "FR19611109". If so, another option you could use is the FILTER function, if it's available in your version of Excel. For example:
=IF(RIGHT(B2, 4)="1101", FILTER($B$2:$B$9, ($A$2:$A$9=A2)*($C$2:$C$9="Salary"), B2), B2)
The only logical_test needed for the IF function in this situation is to check if the right four characters of the code are equal to "1101". It's not necessary to also check if the type is equal to "Salary" because, if true, it would just find and return its own code anyways.
The FILTER function has an optional [if_empty] parameter, which can be used to return the original code if no corresponding "Salary" record is found. If that's not even a possibility with your data, though, you can safely exclude that argument. Cheers!