Home

How do I reference data from one table in a different table?

%3CLINGO-SUB%20id%3D%22lingo-sub-1058669%22%20slang%3D%22en-US%22%3EHow%20do%20I%20reference%20data%20from%20one%20table%20in%20a%20different%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1058669%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all%2C%20this%20is%20my%20first%20post%20here%2C%20so%20hopefully%2C%20I'm%20doing%20everything%20right!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20goal%20here%20is%20to%20add%20up%20some%20values%20from%20one%20table%20in%20an%20excel%20spreadsheet%20together%20and%20have%20that%20sum%20show%20up%20in%20a%20separate%20table.%20To%20be%20more%20specific%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20two%20tables%3A%20player%20stats%2C%20and%20team%20stats.%20I%20wish%20to%20add%20up%20all%20of%20the%20points%20scored%20by%20each%20player%20(listed%20in%20the%20player%20stats%20table)%20and%20have%20that%20total%20show%20up%20in%20the%20%22points%20scored%22%20table%20of%20the%20team%20stats%20column.%20For%20example%2C%20let's%20say%20Player%201%20has%208%20points%20and%20Player%202%20has%206%20points.%20Team%201's%20%22points%20scored%22%20value%20in%20the%20Team%20Stats%20table%20should%20add%20up%20to%2014.%20I%20wish%20to%20do%20this%20for%20several%20teams.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20main%20problem%20is%20there%20are%20several%20different%20statistics%20I%20wish%20to%20sort%20my%20players%20with%20and%20want%20to%20be%20able%20to%20re-sort%20the%20table%20by%20each%20statistic%20without%20breaking%20the%20table%20(which%20is%20why%20I%20don't%20want%20to%20go%20with%20just%20cell%20referencing).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHopefully%2C%20this%20makes%20sense.%20Thanks%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1058669%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1058908%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20reference%20data%20from%20one%20table%20in%20a%20different%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1058908%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F484349%22%20target%3D%22_blank%22%3E%40nhanley19%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20example%20workbook%20to%20play%20with%20would%20be%20nice.%3C%2FP%3E%3CP%3EMy%20thoughts%20at%20this%20stage%20are%20that%2C%20in%20order%20to%20make%20the%20formula%20robust%20against%20sorting%20the%20source%20data%2C%20the%20scores%20must%20be%20looked%20up%20by%20key%20and%20not%20by%20location.%26nbsp%3B%20Using%20a%20dynamic%20array%20version%20of%20Excel%2C%20my%20suggested%20formula%20would%20be%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3D%20SUM(%20XLOOKUP(%20Team%5B%22%40%22%5BPlayerA%5D%3A%5BPlayerB%5D%5D%2C%20Individual%5BPlayer%5D%2C%20Individual%5BScore%5D%20)%20)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CFONT%3Ewhere%3A%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%3E%3CSTRONG%3E%3CFONT%3ETeam%5B%22%40%22%5BPlayerA%5D%3A%5BPlayerB%5D%5D%3C%2FFONT%3E%3C%2FSTRONG%3E%20are%20the%20players%20that%20comprise%20the%20current%20team%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%3E%3CSTRONG%3E%3CFONT%3EXLOOKUP%3C%2FFONT%3E%20%3C%2FSTRONG%3Ereturns%20a%20score%20for%20each%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%3E%3CSTRONG%3ESUM%3C%2FSTRONG%3E%20provides%20a%20team%20score.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3CFONT%3E1.%20I%20could%20well%20have%20got%20the%20wrong%20end%20of%20the%20stick.%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CFONT%3E2.%20Would%20need%20changes%20to%20work%20without%20DA%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CFONT%3E3.%20The%20quotes%20around%20the%20%22%40%22%20symbol%20are%20only%20used%20to%20display%20here%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1058940%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20reference%20data%20from%20one%20table%20in%20a%20different%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1058940%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3BHere's%20the%20Spreadsheet%20I'm%20working%20on%20at%20the%20moment%20(mind%20the%20comical%20names%2C%20they're%20aliases)%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20906px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160958i35D9A4F51E2392E0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22fighterstats.png%22%20title%3D%22fighterstats.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPlayer%20Stats%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F160959i4100ACD675710A0A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22teamstats.png%22%20title%3D%22teamstats.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETeam%20Stats%3C%2FSPAN%3E%3C%2FSPAN%3EI've%20gone%20ahead%20and%20colour%20coded%20each%20player%20to%20the%20team%20they%20belong%20to%20(i.e.%20Meerteo%20and%20Wingus%20are%20both%20red%2C%20as%20they're%20on%20team%20Meerteo%20Brudders%2C%20who%20are%20also%20filled%20in%20with%20red).%20Essentially%2C%20I%20want%20the%20sum%20of%20Meerteo's%20K%20value%20and%20Wingus'%20K%20value%20to%20appear%20under%20Team%20Meerteo%20Brudder's%20K%20value%2C%20if%20possible.%20Ideally%2C%20I'd%20like%20to%20be%20able%20to%20sort%20through%20each%20statistic%20on%20both%20team%20stats%20and%20player%20stats%20without%20breaking%20either%20table%20as%20well.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1059090%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20reference%20data%20from%20one%20table%20in%20a%20different%20table%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059090%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F484349%22%20target%3D%22_blank%22%3E%40nhanley19%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20colourfully%20named%20friends%20present%20no%20problem.%26nbsp%3B%20What%20is%20a%20problem%20is%20that%20there%20is%20nothing%20other%20than%20the%20wild%20markup%20colours%20to%20indicate%20that%20Meerteo%20and%20Wingus%20are%20on%20team%20Meerteo%20Brudders.%3C%2FP%3E%3CP%3EPlayers%20could%20be%20listed%20within%20fields%20of%20the%20team%20table%20or%2C%20alternatively%2C%20they%20could%20be%20assigned%20to%20a%20team%20on%20the%20Player%20table.%26nbsp%3B%20The%20first%20option%20would%20require%20adapting%20my%20formula%20from%20the%20prior%20post%2C%20the%20other%20option%20would%20require%20the%20%3CSTRONG%3ESUMIFS%3C%2FSTRONG%3E%20formula%20to%20pick%20out%20the%20relevant%20scores.%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3D%20SUMIFS(%20Individual%5BScore%5D%2C%20Individual%5BTeam%5D%2C%20%5B%40Team%5D%20)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThis%20approach%20is%20the%20simpler.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
nhanley19
New Contributor

Hello all, this is my first post here, so hopefully, I'm doing everything right!

 

My goal here is to add up some values from one table in an excel spreadsheet together and have that sum show up in a separate table. To be more specific:

 

I have two tables: player stats, and team stats. I wish to add up all of the points scored by each player (listed in the player stats table) and have that total show up in the "points scored" table of the team stats column. For example, let's say Player 1 has 8 points and Player 2 has 6 points. Team 1's "points scored" value in the Team Stats table should add up to 14. I wish to do this for several teams.

 

My main problem is there are several different statistics I wish to sort my players with and want to be able to re-sort the table by each statistic without breaking the table (which is why I don't want to go with just cell referencing).

 

Hopefully, this makes sense. Thanks in advance!

3 Replies

@nhanley19 

An example workbook to play with would be nice.

My thoughts at this stage are that, in order to make the formula robust against sorting the source data, the scores must be looked up by key and not by location.  Using a dynamic array version of Excel, my suggested formula would be

= SUM( XLOOKUP( Team["@"[PlayerA]:[PlayerB]], Individual[Player], Individual[Score] ) )

where:

Team["@"[PlayerA]:[PlayerB]] are the players that comprise the current team;

XLOOKUP returns a score for each;

SUM provides a team score.

 

1. I could well have got the wrong end of the stick.

2. Would need changes to work without DA

3. The quotes around the "@" symbol are only used to display here

 

@Peter Bartholomew Here's the Spreadsheet I'm working on at the moment (mind the comical names, they're aliases):

fighterstats.pngPlayer Stats

teamstats.pngTeam StatsI've gone ahead and colour coded each player to the team they belong to (i.e. Meerteo and Wingus are both red, as they're on team Meerteo Brudders, who are also filled in with red). Essentially, I want the sum of Meerteo's K value and Wingus' K value to appear under Team Meerteo Brudder's K value, if possible. Ideally, I'd like to be able to sort through each statistic on both team stats and player stats without breaking either table as well.

@nhanley19 

Your colourfully named friends present no problem.  What is a problem is that there is nothing other than the wild markup colours to indicate that Meerteo and Wingus are on team Meerteo Brudders.

Players could be listed within fields of the team table or, alternatively, they could be assigned to a team on the Player table.  The first option would require adapting my formula from the prior post, the other option would require the SUMIFS formula to pick out the relevant scores.

= SUMIFS( Individual[Score], Individual[Team], [@Team] )

This approach is the simpler.

Related Conversations