Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 20

Excel-Practice-Online.

com Data Analyst Exam


Below is the lineup of the Nigeria team that played the Nigeria-Iceland match during World Cup 2018 (Which ended 2-0

Complete the following assingments using Excel functions:


1 How many players received a yellow/red card during the game?
2 Return the names of the players that joined the game as substitutes.
3 Return the names of the players that played in more than one position during the game
4 Return the names of the players that played the entire game (From start to the final whistle, without being substituted)

player_id player_na player_ni jersey_nu country cards


3139 Chidozie C Chidozie A 20 Nigeria []

3338 Onyinye WiWilfred Ndi 4 Nigeria []

3647 Alex Iwobi 18 Nigeria []

3708 Kelechi Pr Kelechi Ih 14 Nigeria []

3963 Victor Moses 11 Nigeria []

5454 Francis Od Francis Uz 23 Nigeria []

5455 William Troost-Ekong 5 Nigeria []

5458 Odion JudeOdion Igha 9 Nigeria []

5462 Brian Olad Brian Idow 2 Nigeria [{'time': '4


5464 Simeon To Simy 13 Nigeria []
5466 OghenekarPeter Eteb 8 Nigeria []

5467 Leon Aderemi Balogu 6 Nigeria []


5471 Abdullahi Shehu 12 Nigeria []

5473 Ahmed Musa 7 Nigeria []

5475 John Mich John Obi M 10 Nigeria []

5830 Kenneth JoKenneth O 22 Nigeria []

5832 Tyronne Ebuehi 21 Nigeria []


7470 Joel Chuk Joel Obi 15 Nigeria []
27558 Elderson Uwa Echiejil 3 Nigeria []
33311 Ogenyi EddOgenyi Ona 17 Nigeria []

(Dataset taken from Kaggle - Thanks for that. Click the link to visit!)
the Nigeria-Iceland match during World Cup 2018 (Which ended 2-0 to Nigeria!)

e as substitutes.
than one position during the game
re game (From start to the final whistle, without being substituted)

positions
[]

[{'position_id': 13, 'position': 'Right Center Midfield', 'from': '00:00', 'to': '89:47',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason': 'Tactical
Shift'}, {'position_id': 14, 'position': 'Center Midfield', 'from': '89:47', 'to': None,
'from_period': 2, 'to_period': None, 'start_reason': 'Tactical Shift', 'end_reason':
'Final Whistle'}]

[{'position_id': 15, 'position': 'Left Center Midfield', 'from': '89:40', 'to': '89:47',
'from_period': 2, 'to_period': 2, 'start_reason': 'Substitution - On (Tactical)',
'end_reason': 'Tactical Shift'}, {'position_id': 19, 'position': 'Center Attacking
Midfield', 'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None,
'start_reason': 'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 24, 'position': 'Left Center Forward', 'from': '00:00', 'to': '84:03',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]

[{'position_id': 12, 'position': 'Right Midfield', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]

[{'position_id': 1, 'position': 'Goalkeeper', 'from': '00:00', 'to': None, 'from_period':


1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason': 'Final Whistle'}]

[{'position_id': 4, 'position': 'Center Back', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]

[{'position_id': 24, 'position': 'Left Center Forward', 'from': '84:03', 'to': '89:47',
'from_period': 2, 'to_period': 2, 'start_reason': 'Substitution - On (Tactical)',
'end_reason': 'Tactical Shift'}, {'position_id': 22, 'position': 'Right Center Forward',
'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None, 'start_reason':
'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 16, 'position': 'Left Midfield', 'from': '00:00', 'to': '45:00',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]
[]
[{'position_id': 15, 'position': 'Left Center Midfield', 'from': '00:00', 'to': '89:40',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]

[{'position_id': 3, 'position': 'Right Center Back', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]
[]

[{'position_id': 22, 'position': 'Right Center Forward', 'from': '00:00', 'to': '89:47',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason': 'Tactical
Shift'}, {'position_id': 24, 'position': 'Left Center Forward', 'from': '89:47', 'to':
None, 'from_period': 2, 'to_period': None, 'start_reason': 'Tactical Shift',
'end_reason': 'Final Whistle'}]

[{'position_id': 14, 'position': 'Center Midfield', 'from': '00:00', 'to': '89:47',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason': 'Tactical
Shift'}, {'position_id': 10, 'position': 'Center Defensive Midfield', 'from': '89:47',
'to': '94:47', 'from_period': 2, 'to_period': 2, 'start_reason': 'Tactical Shift',
'end_reason': 'Player Off'}, {'position_id': 10, 'position': 'Center Defensive
Midfield', 'from': '95:13', 'to': None, 'from_period': 2, 'to_period': None,
'start_reason': 'Player On', 'end_reason': 'Final Whistle'}]

[{'position_id': 5, 'position': 'Left Center Back', 'from': '00:00', 'to': '89:47',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason': 'Tactical
Shift'}, {'position_id': 6, 'position': 'Left Back', 'from': '89:47', 'to': None,
'from_period': 2, 'to_period': None, 'start_reason': 'Tactical Shift', 'end_reason':
'Final Whistle'}]

[{'position_id': 16, 'position': 'Left Midfield', 'from': '45:00', 'to': None,


'from_period': 2, 'to_period': None, 'start_reason': 'Substitution - On (Tactical)',
'end_reason': 'Final Whistle'}]
[]
[]
[]

e link to visit!)
Please scroll down to see answers!

player_id player_na player_ni jersey_nu country cards


3139 Chidozie C Chidozie A 20 Nigeria []

3338 Onyinye WiWilfred Ndi 4 Nigeria []

3647 Alex Iwobi 18 Nigeria []

3708 Kelechi Pr Kelechi Ih 14 Nigeria []

3963 Victor Moses 11 Nigeria []

5454 Francis Od Francis Uz 23 Nigeria []

5455 William Troost-Ekong 5 Nigeria []

5458 Odion JudeOdion Igha 9 Nigeria []

5462 Brian Olad Brian Idow 2 Nigeria [{'time': '4


5464 Simeon To Simy 13 Nigeria []

5466 OghenekarPeter Eteb 8 Nigeria []

5467 Leon Aderemi Balogu 6 Nigeria []


5471 Abdullahi Shehu 12 Nigeria []
5473 Ahmed Musa 7 Nigeria []

5475 John Mich John Obi M 10 Nigeria []

5830 Kenneth JoKenneth O 22 Nigeria []

5832 Tyronne Ebuehi 21 Nigeria []


7470 Joel Chuk Joel Obi 15 Nigeria []
27558 Elderson Uwa Echiejil 3 Nigeria []
33311 Ogenyi EddOgenyi Ona 17 Nigeria []

Complete the following assingments using Excel functions:


1 How many players received a yellow/red card during the game?

Answer 1 =COUNTIF(G4:G23,"<>[]")

To count the number of players that received a card (yellow or red), we need to count the entries that are not empty (emp
To do that, we use the COUNTIF function, combined with the <> operator (not equal). We are basically looking for anythin

To learn about COUNTIF and practice it click here!


Click here for additional COUNTIF exercise!

2 Return the names of the players that joined the game as substitutes.

Answer #NAME? {=_xlfn._xlws.filter(C4:C23,ISNUMBER(SEARCH("substitution - on",H4:H23)))}


#NAME?
#NAME?

Players that joined as substitutes, have the following text in their "positions" column:
start_reason': 'Substitution - On (Tactical)'
We can basically ask Excel to keep only rows where "Substitution - On" appears as this is a good indicator for that.
First, we will use the SEARCH function to look for the string "substitution - on" in the "positions" column.

Lets see what we get for the SEARCH function:

#VALUE! {=SEARCH("substitution - on",H4:H23)}


#VALUE!
141
#VALUE!
#VALUE!
#VALUE!
#VALUE!
140
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
134
#VALUE!
#VALUE!
#VALUE!

We can see that only three cells contain a number - that number represents the character position in which "substitution -
Where we see a #VALUE! error we know that we didn't find a match.
Note we used SEARCH as it is not case sensitive (You can also use FIND if you want to perform a case-sensitive check).

Next, we will use the ISNUMBER function to limit the results only to numeric results - meaning that the text was found.

0 {=ISNUMBER(SEARCH("substitution - on",H4:H23))}
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0

Now, we see that wherever we had numbers, the function returned TRUE!

Finally, we use the FILTER function to filter the data in column C (The names), based on the criteria in column H (look for ro

#NAME? {=_xlfn._xlws.filter(C4:C23,ISNUMBER(SEARCH("substitution - on",H4:H23)))}


#NAME?
#NAME?

You may have noticed that we wrote each function only once, instead of repeating it for all the rows.
This is achieved by Excel's ability to "SPILL" cells. This is a new ability that can make your formula-writing experience much
Read more about SPILLED ranges and Dynamic Array Formulas here.
To read more about the SEARCH function and practice it click here!
To read and practice the FIND function click here!
To read more about ISNUMBER (and other IS functions) click here!
to read more abou the FILTER function (and practice, of course...) click here!

3 Return the names of the players that played in more than one position during the game

#NAME? {=_xlfn._xlws.filter(C4:C23,(LEN(H4:H23)-LEN(SUBSTITUTE(H4:H23,"position_id","")))/LE
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

Easy, right? :-)


OK, Let's break this down to understand what we tried to achieve here!

First, we need to understand what strategy we are going to use in order to find the players who played in more than one p
Let's look at Onyinye Wilfred Ndidi's data:

[{'position_id': 13, 'position': 'Right Center Midfield', 'from':


'00:00', 'to': '89:47', 'from_period': 1, 'to_period': 2,
'start_reason': 'Starting XI', 'end_reason': 'Tactical Shift'},
{'position_id': 14, 'position': 'Center Midfield', 'from': '89:47',
'to': None, 'from_period': 2, 'to_period': None, 'start_reason':
'Tactical Shift', 'end_reason': 'Final Whistle'}]
We can understand that the player played in the beginning as a Right Center Midfield, but then he switched to Center Mid
We can understand that two positions were played and we can see that the text "position_id" appears twice.
We will look for players that had more than one "position_id" as an indicator for playing more than one position during the

Now, how do we count the number of occurences of "position_id" for each player's data?
We can do the following trick:
Basically, we check for the length of each text as a whole.
From the length we received, we substract the length of everything except the found occurence(s).
Finally, we divide the length we found which is the total length of all the occurences of the word, by the length of a single

Let's do it step by step:

#1 - Check length of the entire text:

2 {=LEN(H4:H23)}
370
396
200
179
174
175
390
194
2
201
181
2
373
559
357
195
2
2
2

The LEN function is used to check a length of a text.


Click here to learn and practice LEN function!

#2 - Check length of everything except the words we are looking for (position_id)

2 {=LEN(SUBSTITUTE(H4:H23,"position_id",""))}
348
374
189
168
163
164
368
183
2
190
170
2
351
526
335
184
2
2
2

The SUBSTITUTE function is used here to replace each occurence of "position_id" with an empty text.
The result we get is the length of everything minus the length of word(s) we were looking for.

Click here to learn and practice SUBSTITUTE function!

Finally, we subtract the lengths to find only the length of the words we were looking for.
To translate the length into number of occurences, we will divide this length by the length of a single word.

0 {=(LEN(H4:H23)-LEN(SUBSTITUTE(H4:H23,"position_id","")))/LEN("position_id")}
2
2
1
1
1
1
2
1
0
1
1
0
2
3
2
1
0
0
0
And finally, we use the FILTER function, we mentioned above, to show only occurences with more than 1 position_id!

#NAME? {=_xlfn._xlws.filter(C4:C23,(LEN(H4:H23)-LEN(SUBSTITUTE(H4:H23,"position_id","")))/LE
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

4 Return the names of the players that played the entire game (From start to the final whistle, without being substituted)

#NAME? {=_xlfn._xlws.filter(C4:C23,(ISNUMBER(SEARCH("Starting XI",H4:H23))*(ISNUMBER(SEAR


#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

In this question, we wish to find players that were included in the Starting 11 ("Starting XI"), and that they played until "Fin
As there are two criteria here, we need to multiply these two criteria. The filter function will show only rows where these

Let see which players were in the starting 11:

#NAME? {=_xlfn._xlws.filter(C4:C23,(ISNUMBER(SEARCH("Starting XI",H4:H23))))}


#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

Now, which players played until the final whistle?

#NAME? {=_xlfn._xlws.filter(C4:C23,(ISNUMBER(SEARCH("Final Whistle",H4:H23))))}


#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

In green, we can see the only 8 players that were both in the Starting 11 and played until the Final Whistle.
This make sense to us, as we know that we had 3 substitutions made during the game (11-3=8)

Click here for more information on the usage of FILTER function with multiple criteria
positions
[]

[{'position_id': 13, 'position': 'Right Center Midfield', 'from': '00:00', 'to':


'89:47', 'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI',
'end_reason': 'Tactical Shift'}, {'position_id': 14, 'position': 'Center Midfield',
'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None, 'start_reason':
'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 15, 'position': 'Left Center Midfield', 'from': '89:40', 'to': '89:47',
'from_period': 2, 'to_period': 2, 'start_reason': 'Substitution - On (Tactical)',
'end_reason': 'Tactical Shift'}, {'position_id': 19, 'position': 'Center Attacking
Midfield', 'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None,
'start_reason': 'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 24, 'position': 'Left Center Forward', 'from': '00:00', 'to': '84:03',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]

[{'position_id': 12, 'position': 'Right Midfield', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]

[{'position_id': 1, 'position': 'Goalkeeper', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]

[{'position_id': 4, 'position': 'Center Back', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]

[{'position_id': 24, 'position': 'Left Center Forward', 'from': '84:03', 'to': '89:47',
'from_period': 2, 'to_period': 2, 'start_reason': 'Substitution - On (Tactical)',
'end_reason': 'Tactical Shift'}, {'position_id': 22, 'position': 'Right Center
Forward', 'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None,
'start_reason': 'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 16, 'position': 'Left Midfield', 'from': '00:00', 'to': '45:00',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]
[]

[{'position_id': 15, 'position': 'Left Center Midfield', 'from': '00:00', 'to': '89:40',
'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Substitution - Off (Tactical)'}]

[{'position_id': 3, 'position': 'Right Center Back', 'from': '00:00', 'to': None,


'from_period': 1, 'to_period': None, 'start_reason': 'Starting XI', 'end_reason':
'Final Whistle'}]
[]
[{'position_id': 22, 'position': 'Right Center Forward', 'from': '00:00', 'to':
'89:47', 'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI',
'end_reason': 'Tactical Shift'}, {'position_id': 24, 'position': 'Left Center
Forward', 'from': '89:47', 'to': None, 'from_period': 2, 'to_period': None,
'start_reason': 'Tactical Shift', 'end_reason': 'Final Whistle'}]

[{'position_id': 14, 'position': 'Center Midfield', 'from': '00:00', 'to': '89:47',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Tactical Shift'}, {'position_id': 10, 'position': 'Center Defensive Midfield', 'from':
'89:47', 'to': '94:47', 'from_period': 2, 'to_period': 2, 'start_reason': 'Tactical
Shift', 'end_reason': 'Player Off'}, {'position_id': 10, 'position': 'Center
Defensive Midfield', 'from': '95:13', 'to': None, 'from_period': 2, 'to_period':
None, 'start_reason': 'Player On', 'end_reason': 'Final Whistle'}]

[{'position_id': 5, 'position': 'Left Center Back', 'from': '00:00', 'to': '89:47',


'from_period': 1, 'to_period': 2, 'start_reason': 'Starting XI', 'end_reason':
'Tactical Shift'}, {'position_id': 6, 'position': 'Left Back', 'from': '89:47', 'to':
None, 'from_period': 2, 'to_period': None, 'start_reason': 'Tactical Shift',
'end_reason': 'Final Whistle'}]

[{'position_id': 16, 'position': 'Left Midfield', 'from': '45:00', 'to': None,


'from_period': 2, 'to_period': None, 'start_reason': 'Substitution - On
(Tactical)', 'end_reason': 'Final Whistle'}]
[]
[]
[]

(yellow or red), we need to count the entries that are not empty (empty in our example means: [] ).
with the <> operator (not equal). We are basically looking for anything which is not equal to [])

e as substitutes.

C4:C23,ISNUMBER(SEARCH("substitution - on",H4:H23)))}

text in their "positions" column:


Substitution - On" appears as this is a good indicator for that.
string "substitution - on" in the "positions" column.

hat number represents the character position in which "substitution - on" was found in the text.
n't find a match.
can also use FIND if you want to perform a case-sensitive check).

results only to numeric results - meaning that the text was found.
nction returned TRUE!

n column C (The names), based on the criteria in column H (look for rows where "substitution - on" was found in the text).

UMBER(SEARCH("substitution - on",H4:H23)))}

nly once, instead of repeating it for all the rows.


is a new ability that can make your formula-writing experience much more efficient.
Formulas here.
e it click here!

ns) click here!


of course...) click here!

than one position during the game

C4:C23,(LEN(H4:H23)-LEN(SUBSTITUTE(H4:H23,"position_id","")))/LEN("position_id")>1)}

ed to achieve here!

oing to use in order to find the players who played in more than one position.
inning as a Right Center Midfield, but then he switched to Center Midfield in 89:47.
nd we can see that the text "position_id" appears twice.
ition_id" as an indicator for playing more than one position during the game.

"position_id" for each player's data?

h of everything except the found occurence(s).


otal length of all the occurences of the word, by the length of a single occurence.

e are looking for (position_id)


h occurence of "position_id" with an empty text.
he length of word(s) we were looking for.

h of the words we were looking for.


e will divide this length by the length of a single word.

TE(H4:H23,"position_id","")))/LEN("position_id")}
d above, to show only occurences with more than 1 position_id!

C4:C23,(LEN(H4:H23)-LEN(SUBSTITUTE(H4:H23,"position_id","")))/LEN("position_id")>1)}

re game (From start to the final whistle, without being substituted)

C4:C23,(ISNUMBER(SEARCH("Starting XI",H4:H23))*(ISNUMBER(SEARCH("Final Whistle",H4:H23)))))}

cluded in the Starting 11 ("Starting XI"), and that they played until "Final_Whistle".
hese two criteria. The filter function will show only rows where these two criteria are met.

xlws.filter(C4:C23,(ISNUMBER(SEARCH("Starting XI",H4:H23))))}

xlws.filter(C4:C23,(ISNUMBER(SEARCH("Final Whistle",H4:H23))))}
h in the Starting 11 and played until the Final Whistle.
stitutions made during the game (11-3=8)

ER function with multiple criteria

You might also like