Index Match Query

kankana

New Member
Joined
Sep 19, 2017
Messages
3
Hi Folks,

Can you please help me with the below query:

Master Data:

[TABLE="width: 198"]
<colgroup><col><col span="2"></colgroup><tbody>[TR]
[TD]Username[/TD]
[TD]Subject[/TD]
[TD]Score[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]English[/TD]
[TD="align: right"]50[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]Maths[/TD]
[TD="align: right"]45[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]Physics[/TD]
[TD="align: right"]34[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]History[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]Geography[/TD]
[TD="align: right"]56[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]English[/TD]
[TD="align: right"]24[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]Maths[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]Physics[/TD]
[TD="align: right"]45[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]History[/TD]
[TD="align: right"]32[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]English[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]Maths[/TD]
[TD="align: right"]89[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]Physics[/TD]
[TD="align: right"]65[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]History[/TD]
[TD="align: right"]75[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]Geography[/TD]
[TD="align: right"]72[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]Maths[/TD]
[TD="align: right"]45[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]Physics[/TD]
[TD="align: right"]25[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]History[/TD]
[TD="align: right"]67[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]Geography[/TD]
[TD="align: right"]45[/TD]
[/TR]
</tbody>[/TABLE]

Result Data:

[TABLE="width: 380"]
<colgroup><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Username[/TD]
[TD]History[/TD]
[TD]Physics[/TD]
[TD]Geography[/TD]
[TD]Maths[/TD]
[TD]English[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]

Please help
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
A couple of possibilities:


Book1
ABCDEFGHIJ
1UsernameSubjectScoreUsernameHistoryPhysicsGeographyMathsEnglish
2A1English50A12334564550
3A1Maths45A2324506724
4A1Physics34A37565728967
5A1History23A4672545450
6A1Geography56
7A2English24UsernameHistoryPhysicsGeographyMathsEnglish
8A2Maths67A12334564550
9A2Physics45A232456724
10A2History32A37565728967
11A3English67A467254545
12A3Maths89
13A3Physics65
14A3History75
15A3Geography72
16A4Maths45
17A4Physics25
18A4History67
19A4Geography45
Sheet1
Cell Formulas
RangeFormula
F2=SUMPRODUCT(($A$2:$A$19=$E2)*($B$2:$B$19=F$1),$C$2:$C$19)
F8{=IFERROR(VLOOKUP($E8&F$7,CHOOSE({1,2},$A$2:$A$19&$B$2:$B$19,$C$2:$C$19),2,0),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.


Note the second one will show blank if there is no record but the first one will show zero. Of course, you can also format the cell to show zero as blank.

WBD
 
Upvote 0
Thanks so much for the help. I have tried the first one and its working for one cell and when i am dragging the formula its not returning the actual result. can you please suggest?



A couple of possibilities:

ABCDEFGHIJ
UsernameSubjectScoreUsernameHistoryPhysicsGeographyMathsEnglish
A1EnglishA1
A1MathsA2
A1PhysicsA3
A1HistoryA4
A1Geography
A2EnglishUsernameHistoryPhysicsGeographyMathsEnglish
A2MathsA1
A2PhysicsA2
A2HistoryA3
A3EnglishA4
A3Maths
A3Physics
A3History
A3Geography
A4Maths
A4Physics
A4History
A4Geography

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]50[/TD]
[TD="align: right"][/TD]

[TD="align: right"]23[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]50[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]45[/TD]
[TD="align: right"][/TD]

[TD="align: right"]32[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]67[/TD]
[TD="align: right"]24[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]34[/TD]
[TD="align: right"][/TD]

[TD="align: right"]75[/TD]
[TD="align: right"]65[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]89[/TD]
[TD="align: right"]67[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]23[/TD]
[TD="align: right"][/TD]

[TD="align: right"]67[/TD]
[TD="align: right"]25[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]0[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]56[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]24[/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]67[/TD]
[TD="align: right"][/TD]

[TD="align: right"]23[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]50[/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]45[/TD]
[TD="align: right"][/TD]

[TD="align: right"]32[/TD]
[TD="align: right"]45[/TD]

[TD="align: right"]67[/TD]
[TD="align: right"]24[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]32[/TD]
[TD="align: right"][/TD]

[TD="align: right"]75[/TD]
[TD="align: right"]65[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]89[/TD]
[TD="align: right"]67[/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]67[/TD]
[TD="align: right"][/TD]

[TD="align: right"]67[/TD]
[TD="align: right"]25[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]45[/TD]

[TD="align: center"]12[/TD]

[TD="align: right"]89[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]

[TD="align: right"]65[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]

[TD="align: right"]75[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]15[/TD]

[TD="align: right"]72[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]16[/TD]

[TD="align: right"]45[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]17[/TD]

[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]18[/TD]

[TD="align: right"]67[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]19[/TD]

[TD="align: right"]45[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F2[/TH]
[TD="align: left"]=SUMPRODUCT(($A$2:$A$19=$E2)*($B$2:$B$19=F$1),$C$2:$C$19)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F8[/TH]
[TD="align: left"]{=IFERROR(VLOOKUP($E8&F$7,CHOOSE({1,2},$A$2:$A$19&$B$2:$B$19,$C$2:$C$19),2,0),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]



Note the second one will show blank if there is no record but the first one will show zero. Of course, you can also format the cell to show zero as blank.

WBD
 
Upvote 0
You have to have careful use of the "$" anchors. Make sure that you have something like this:

Code:
=SUMPRODUCT(($A$2:$A$19=$E2)*($B$2:$B$19=F$1),$C$2:$C$19)

$A$2:$A$19 is the range of usernames
$E2 is the cell that contains the usernames. The $E part ensures that the column doesn't change when you paste the formula across
$B$2:$B$19 is the range of subjects
F$1 is the cell that contains the subject. The $1 part ensures that the row doesn't change when you paste the formula down
$C$2:$C$19 is the range of scores

In my example I copied the formula across and down without issue and the values returned as expected.

WBD
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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