SOLVED

Excel formula for finding unique matches

%3CLINGO-SUB%20id%3D%22lingo-sub-1445379%22%20slang%3D%22en-US%22%3EExcel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445379%22%20slang%3D%22en-US%22%3E%3CP%3EHello.%20I%20run%20the%20schedule%20for%20a%20recreational%20soccer%20league%20and%20need%20help%20with%20a%20formula.%20Columns%20D%20and%20G%20list%20the%20teams%20versing%20on%20Mondays%20while%20columns%20L%20and%20O%20list%20the%20teams%20versing%20on%20Wednesdays.%20Teams%20play%20each%20other%20at%20least%20once%20and%20some%20teams%20will%20play%20each%20other%20twice.%20I%20need%20a%20formula%20that%20looks%20through%20all%20the%20games%20and%20counts%20how%20many%20distinct%20teams%20each%20team%20plays.%20This%20will%20ensure%20that%20the%20schedule%20is%20correct%20and%20each%20team%20plays%20all%20the%20other%20teams%20at%20least%20once.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wanted%20to%20have%20the%20formula%20in%20Y47%20through%20Y56%20and%20if%20the%20schedule%20is%20correct%2C%20the%20value%20the%20formula%20should%20return%20is%209%20(10%20teams%20means%20that%20the%20number%20of%20possible%20distinct%20games%20is%209).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20possible%20to%20to%3F%20Can%20anyone%20help%20with%20this%3F%20Thank%20you%20much%20for%20any%20assistance%20you%20can%20provide.%20I%20attached%20the%20file%20to%20the%20post.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1445379%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445435%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445435%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691039%22%20target%3D%22_blank%22%3E%40MountainView%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20not%20sure%20if%20this%20is%20what%20you%20want%3F%3C%2FP%3E%3CP%3EIn%20column%20Y%20I%20have%20added%20up%20how%20many%20times%20each%20team%20plays%20on%20Monday.%20This%20shows%20that%20team%20WHITE%20plays%2010%20times%20including%20playing%20twice%20against%20both%20GREEN%20and%20RED.%20I%20am%20guessing%20this%20is%20wrong%3F%3C%2FP%3E%3CP%3EIn%20column%20AB%20I%20show%20the%20totals%20for%20the%20Wednesday%20matches.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20a%20look%20and%20see%20id%20this%20is%20what%20you%20need.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPeter%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445620%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445620%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691039%22%20target%3D%22_blank%22%3E%40MountainView%3C%2FA%3E%26nbsp%3BI%20am%20able%20to%20obtain%20the%20expected%20results%20as%20shown%20in%20the%20attached%20workbook%20with%202%20alternative%20solutions%3A%3C%2FP%3E%3CP%3E-%20The%201st%20one%3A%20create%20a%20pivot%20table%20from%202%20Home%20Team%20-%20Away%20Team%20ranges%20(D10%3AG46%20and%20L10%3AO46).%20To%20create%20a%20pivot%20table%20from%20multiple%20ranges%2C%20use%20shortcut%20Alt%2BD%2BP%20then%20follow%20instructions%20at%20this%20link%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.contextures.com%2FxlPivot08.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.contextures.com%2FxlPivot08.html.%3C%2FA%3E%3C%2FP%3E%3CP%3ETeamA%20in%20my%20pivot%20table%20is%20actually%20Row%20field%20and%20TeamB%20is%20actually%20Value%20field.%20Then%20I%20use%20additional%20column%20next%20to%20the%20pivot%20table%20to%20count%20the%20occurrence%20of%20same%20team%20pair%20but%20with%20reverse%20order.%20Finally%2C%20the%20result%20will%20be%20the%20addition%20of%202%20simple%20countif%20formulas%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-%20The%202nd%20one%3A%20use%20TextJoin%20to%20combine%20Home%20Team%20and%20Away%20Team%20from%20both%20ranges%20(D%3AG%20and%20L%3AO)%20into%20a%20same%20column%20A%20in%20a%20new%20Tab.%20Then%20use%20formula%20to%20fill%20all%20counts%20in%20the%201st%20matrix%20of%20all%20combinations.%20The%202nd%20matrix%20is%20based%20on%20the%20result%20of%20the%201st%20matrix%20and%20only%20generate%20distinct%20count.%20Finally%2C%20sum%20up%20either%20horizontally%20or%20vertically%20for%20each%20team%20to%20get%20the%20desired%20output%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445695%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445695%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F691039%22%20target%3D%22_blank%22%3E%40MountainView%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20couldn't%20quite%20find%20a%20single%20formula%20that%20would%20do%20the%20trick%20but%20I%20did%20populate%20your%20desired%20cells%20with%20the%20desired%20results.%26nbsp%3B%20I%20kept%20all%20my%20formulas%20to%20the%20right%20so%20they%20could%20be%20easily%20hidden.%26nbsp%3B%20My%20formulas%20utilize%20the%20new%20SORT%20and%20UNIQUE%20functions%20so%20this%20spreadsheet%20will%20not%20work%20properly%20in%20any%20version%20of%20Excel%20prior%20to%202016.%26nbsp%3B%20I%20also%20added%20an%20alternative%20view%20of%20the%20team%20pairs%20so%20you%20can%20see%20which%20team%20pairs%20play%20only%20once%20and%20which%20pairs%20play%20more%20than%20once.%26nbsp%3B%20I%20did%20this%20because%20the%20answer%20you%20are%20looking%20for%20could%20be%20misleading.%26nbsp%3B%20If%20I%20changed%20one%20of%20the%20teams%20playing%20together%20of%20a%20pair%20that%20is%20playing%202%20games%20in%20the%20season%20then%20uniqueness%20will%20remain%20at%209.%26nbsp%3B%20If%20I%20changed%20one%20of%20the%20teams%20for%20a%20pair%20that%20is%20playing%20only%201%20game%20together%20then%20the%20uniqueness%20drops%20to%208%20as%20expected.%3C%2FP%3E%3CP%3EThe%20approach%20that%20I%20used%20was%20to%20first%20get%20versing%20teams%20to%20consistently%20match%20up%20the%20same%20way.%26nbsp%3B%20I%20did%20this%20using%20CONCAT(SORT(D10%3AG10%2C%2C1%2CTRUE))%26nbsp%3B%20This%20gives%20me%20something%20like%20%22BlackOrange%22%20even%20if%20the%20home%20team%20is%20Orange.%26nbsp%3B%20I%20then%20added%20a%20COUNT%20on%20the%20results%20making%20it%20easy%20to%20see%20which%20team%20pairs%20play%20only%20one%20game%20together%20and%20which%20ones%20play%20more%20than%20once.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445898%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445898%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20help%2C%20Peter%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F667968%22%20target%3D%22_blank%22%3E%40peteryac60%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445899%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445899%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20help.%20I%20like%20the%20second%20option.%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445911%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20formula%20for%20finding%20unique%20matches%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445911%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20much.%20That's%20what%20I%20was%20looking%20for%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F307537%22%20target%3D%22_blank%22%3E%40xspJody%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello. I run the schedule for a recreational soccer league and need help with a formula. Columns D and G list the teams versing on Mondays while columns L and O list the teams versing on Wednesdays. Teams play each other at least once and some teams will play each other twice. I need a formula that looks through all the games and counts how many distinct teams each team plays. This will ensure that the schedule is correct and each team plays all the other teams at least once.

 

I wanted to have the formula in Y47 through Y56 and if the schedule is correct, the value the formula should return is 9 (10 teams means that the number of possible distinct games is 9).

 

Is this possible to to? Can anyone help with this? Thank you much for any assistance you can provide. I attached the file to the post.

6 Replies
Highlighted

@MountainView 

 

Hi 

I am not sure if this is what you want?

In column Y I have added up how many times each team plays on Monday. This shows that team WHITE plays 10 times including playing twice against both GREEN and RED. I am guessing this is wrong?

In column AB I show the totals for the Wednesday matches. 

 

Have a look and see id this is what you need.

 

thanks

 

Peter

Highlighted

@MountainView I am able to obtain the expected results as shown in the attached workbook with 2 alternative solutions:

- The 1st one: create a pivot table from 2 Home Team - Away Team ranges (D10:G46 and L10:O46). To create a pivot table from multiple ranges, use shortcut Alt+D+P then follow instructions at this link: https://www.contextures.com/xlPivot08.html.

TeamA in my pivot table is actually Row field and TeamB is actually Value field. Then I use additional column next to the pivot table to count the occurrence of same team pair but with reverse order. Finally, the result will be the addition of 2 simple countif formulas

 

- The 2nd one: use TextJoin to combine Home Team and Away Team from both ranges (D:G and L:O) into a same column A in a new Tab. Then use formula to fill all counts in the 1st matrix of all combinations. The 2nd matrix is based on the result of the 1st matrix and only generate distinct count. Finally, sum up either horizontally or vertically for each team to get the desired output

Highlighted
Solution

@MountainView 

I couldn't quite find a single formula that would do the trick but I did populate your desired cells with the desired results.  I kept all my formulas to the right so they could be easily hidden.  My formulas utilize the new SORT and UNIQUE functions so this spreadsheet will not work properly in any version of Excel prior to 2016.  I also added an alternative view of the team pairs so you can see which team pairs play only once and which pairs play more than once.  I did this because the answer you are looking for could be misleading.  If I changed one of the teams playing together of a pair that is playing 2 games in the season then uniqueness will remain at 9.  If I changed one of the teams for a pair that is playing only 1 game together then the uniqueness drops to 8 as expected.

The approach that I used was to first get versing teams to consistently match up the same way.  I did this using CONCAT(SORT(D10:G10,,1,TRUE))  This gives me something like "BlackOrange" even if the home team is Orange.  I then added a COUNT on the results making it easy to see which team pairs play only one game together and which ones play more than once.

Highlighted

Thank you for your help, Peter@peteryac60 

Highlighted

Thank you for your help. I like the second option.@hynguyen 

Highlighted

Thank you much. That's what I was looking for@xspJody