mercredi 31 juillet 2019

How to index match a condition set in a cell

I am trying to avoid having a multiple if formula by index matching a table instead, however what i need to match is the actual condition and a string.

Lookup table:

+---+------------------+-------------------+-------+
|   |        A         |         B         |   C   |
+---+------------------+-------------------+-------+
| 1 | Current to Prior | Portfolio Comment | Error |
| 2 | =0               | ""                | 1     |
| 3 | <>0              | ""                | -1    |
| 4 | >0               | OK – Losses       | 0     |
| 5 | <0               | OK – Losses       | 1     |
| 6 | <0               | OK – New Sales    | 0     |
| 7 | >0               | OK – New Sales    | 1     |
+---+------------------+-------------------+-------+

  • Column A: Lookup Condition
  • Column B: Lookup string
  • Column C: Return value

Data example with correct hard coded output (column C):

+---+------------------+-------------------+-------+
|   |        A         |         B         |   C   |
+---+------------------+-------------------+-------+
| 1 | Current to Prior | Portfolio comment | Error |
| 2 | 0                |                   | 1     |
| 3 | -100             | OK – Losses       | 1     |
| 4 | 50               |                   | -1    |
| 5 | 200              | OK – Losses       | 0     |
| 6 | 0                |                   | 1     |
| 7 | -400             | OK – New Sales    | 0     |
| 8 | 0                |                   | 1     |
+---+------------------+-------------------+-------+

  • Column A: Data value
  • Column B: Data string
  • Column C: Output formula

I need a formula that matches the data value with the lookup condition, the data string with the lookup string and outputs the return value.

Aucun commentaire:

Enregistrer un commentaire