Home > database >  Calculate Positional Difference based on row for string values for two tables
Calculate Positional Difference based on row for string values for two tables

Time:08-06

Table 1:

Position Team
1 MCI
2 LIV
3 MAN
4 CHE
5 LEI
6 AST
7 BOU
8 BRI
9 NEW
10 TOT

Table 2

Position Team
1 LIV
2 MAN
3 MCI
4 CHE
5 AST
6 LEI
7 BOU
8 TOT
9 BRI
10 NEW

Output I'm looking for is Position difference = 10 as that is the total of the positional difference. How can I do this in excel/google sheets? So the positional difference is always a positive even if it goes up or down. Think of it as a league table.

Table 2 New (using formula to find positional difference):

Position Team Positional Difference
1 LIV 1
2 MAN 1
3 MCI 2
4 CHE 0
5 AST 1
6 LEI 1
7 BOU 0
8 TOT 2
9 BRI 1
10 NEW 1

CodePudding user response:

Try this:

=IFNA(ABS(INDEX(A:B,MATCH(E2,B:B,0),1)-D2),"-")

Assuming that table 1 is at columns A:B:

Example output

  • Related