Index match multiple columns and true/false statement

Triarch

New Member
Joined
Mar 27, 2023
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I need to find the row that matches the most number of parameters.
I have two datasheets. One table "Table23" with a set of rules that can contain a specific value or a *.
Table23:
1679927996153.png


In the second table I need to get values and match them against this table to find the truest match and return the value in the Value column.
I have made calculations on each of the row separately to get total matches =($G$2=Table23[@Id1])+($H$2=Table23[@Id2])+($I$2=Table23[@Id3])+($J$2=Table23[@Id4])
and a second calculation to get the true/false value: =AND(OR($G$2=Table23[@Id1];"X"=Table23[@Id1]);OR($H$2=Table23[@Id2];"X"=Table23[@Id2]);OR($I$2=Table23[@Id3];"X"=Table23[@Id3]);OR($J$2=Table23[@Id4];"X"=Table23[@Id4]))

These work perfectly, if i multiply them with eachother i get the desired result per row.

But I want to do this in an array but my logic seems off. The formula I am using is
=INDEX(Table23[Value];MATCH(
MAX(((G2=Table23[Id1])+(H2=Table23[Id2])+(I2=Table23[Id3])+(J2=Table23[Id4]))
*AND(OR(G2=Table23[Id1];"*"=Table23[Id1]);OR(H2=Table23[Id2];"*"=Table23[Id2]);OR(I2=Table23[Id3];"*"=Table23[Id3]);OR(J2=Table23[Id4];"*"=Table23[Id4])));
((G2=Table23[Id1])+(H2=Table23[Id2])+(I2=Table23[Id3])+(J2=Table23[Id4]))
*AND(OR(G2=Table23[Id1];"*"=Table23[Id1]);OR(H2=Table23[Id2];"*"=Table23[Id2]);OR(I2=Table23[Id3];"*"=Table23[Id3]);OR(J2=Table23[Id4];"*"=Table23[Id4]));0);0)

From my own troubleshooting it appears that the true/false statement isn't working per row.

Thankful for any help I could get on this.

Regards, Thomas
 
Be aware that if you use more than 4 ID columns, the formula will have to be changed a bit. But I'm glad I could help, thanks for the feedback. :cool:
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I Will need to use it for 3-6 match values in different searches. How Will it need to be altered?
 
Upvote 0
=IFERROR(MOD(AGGREGATE(14,6,EXP(LN(MMULT(IF(G2:J2=Table23[[ID1]:[ID4]],1,IF(Table23[[ID1]:[ID4]]<>"X",-10,0)),{1;1;1;1})))+Table23[Value]/1000,1),1)*1000,INDEX(Table23[Value],1))

The array constant (in red) needs to have a 1 for each column. 4 columns, 4 1s. The blue -10 needs to be bigger in magnitude than the number of columns you're comparing. So if you go to 6, it won't have to change. And of course, the ranges (G2:J2) will have to change, as well as the Table references.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top