Battle Functions FullStackModeller 1.01
Battle Functions FullStackModeller 1.01
Version Log
Purpose
This training workbook will guide you through a selection of functions we believe you should master, whethe
It's not intended to be an exhaustive list, and there will undoubtedly be other functions you could use in the b
However, it's our belief that mastering the functions we have picked out for you here will give you an incredib
Generally each tab introduces an individual function, providing examples of its use and some exercises for y
The workbook also includes additional exercises (on blue tabs) for you to put into practice what you have lea
You will see references to someone called Sarah and her bakery business. This is a fictional business owne
Format guide
Cells with a yellow fill are inputs cells which you can populate with your own inputs / assumpt
1 Formulas will be found in grey fill cells like this one. You will be expected to populate grey fill
Note: We have made every effort possible to remove typos and other minor errors. However, this is a big w
If you do spot something that looks wrong, please email Giles at [email protected] or contact him
We will continue to offer this workbook for free via a shared drive link, and we'll ensure it's updated regularly
Enjoy!
should master, whether you'd like to take part in the Excel Battle Series or to just generally improve your modelling skills.
s you could use in the battles to great effect.
will give you an incredible base of fundamentals you can then build upon.
nd some exercises for you to work through.
ctice what you have learned, with supporting answers for you to refer to.
fictional business owner we created for much of our training content at Full Stack Modeller. You do not need any wider context a
However, this is a big workbook, and there's every chance we've missed one somewhere!
eller.com or contact him on LinkedIn to let him know.
re it's updated regularly with any fixes.
or to just generally improve your modelling skills.
ull Stack Modeller. You do not need any wider context about her business to complete the exercises in this model.
one somewhere!
context about her business to complete the exercises in this model.
The LEFT function
Key points
The LEFT function allows you to extract a specified number of characters from a text string, starting from the left side of the string
Below is our base text string. We need to extract some characters and we start from the left hand side of the string.
The first element of the LEFT function identifies the text string, and the second part (after the comma) identifies the number of characters that will be returned
In plain English:
The LEFT function returns the first 21 characters from the left of the text string in cell C15
In the example above the text string is linked through from another cell. In addition we can identify the number of characters through a cell reference:
text num_chars
************ 5623154 - Debtors 21 ************ 5623154 =LEFT(C27, D27)
Application
Sarah has some PO data that she needs some help with. The first eight characters are the actual PO numbers
This can be particularly useful, and quick to use, when you have text data that is consistent in length and structure:
Note that we are referencing a range in our grey calculation cell above, and returning a dynamic array in this instance
Exercise
Use the LEFT function to extract the month text from the text strings below
Exercise Solution
Use the LEFT function to extract the month text from the text strings below
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The RIGHT function
Key points
The RIGHT function allows you to extract a specified number of characters from a text string, starting from the right side of the string
Below is our base text string. We need to extract some characters and we start from the right hand side of the string.
The first element of the RIGHT function identifies the text string, and the second part (after the comma) identifies the number of characters that will be returned
In plain English:
The RIGHT function returns the first 7 characters from the right of the text string in cell C15
In the example above the text string is linked through from another cell. Just as we showed you with LEFT, we can identify the number of characters through a cell reference as well
text num_chars
************ 5623154 - Debtors 7 Debtors =RIGHT(C27, D27)
Application
Sarah has some PO data that she needs some help with. The last twelve characters are unique system references
Using the same simple example we saw on the LEFT tab, you'll see that the logic doesn't work so well with RIGHT if we want to extract the day text at the end of the string below, because the number of characters varies:
Exercise
Use the RIGHT function to extract the customer contact name reference from the text strings below
Exercise Solution
Use the RIGHT function to extract the customer contact name reference from the text strings below
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The LEN function
Syntax =LEN(text)
text - The text string to measure the length of (the number of characters)
Key points
The LEN function allows you to return the number of characters in a text string.
It does not discriminate between text, numbers, and spaces.
Bear with us on this function. Its value may not be obvious, but when combined with other text functions it can be a very powerful tool.
This is our base text string which we will refer to with the LEN function to return the number of characters
There is just one element of the LEN function - the cell reference for which you would like to return the number of characters
In plain English:
How long is the text string in cell C16?
Application
Using the LEN function to return the number of characters in a text string
As we have seen above, we use the LEN function on its own simply to return the number of characters
1573f821-af6e-4826-8bd7-63c10f701efb 36 =LEN(C29)
f46a8843-41cf-4ef6-at56-e37067a67149 36 =LEN(C30)
3b27d9e0-41f7-408c-98fe-6038eeab7261 36 =LEN(C31)
c4t30530-91d8-4508-b355-fb58a28046d3 36 =LEN(C32)
d11512d1-150b-47dr-990e-b134323debbf 36 =LEN(C33)
bd40b730-f76d-26db-857d-f1692b6fb8 34 =LEN(C34)
Let's say we wanted to extract the day text from the right hand side of the data table below.
The challenge here is that the day text string length is not consistent.
A useful first step in helping us solve this problem is simply using LEN to calculate the total text string length:
We'll come back to this again later (once we've introduced some other functions)
Exercise
Use the LEN function to return the number of characters from the text strings below
Exercise Solution
Use the LEN function to return the number of characters from the text strings below
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The FIND function
Key points
The FIND function allows you to find the position of specified text (or individual characters) from within a text string.
The [start_num] allows you to start the search within the text string from a specified position (a number of characters from furthest left).
The FIND function is case sensitive. SEARCH, which we'll mention below, is case sensitive, which makes it worth remembering alongside FIND.
This is our base text string which we will refer to with the FIND function to return a relative position of a determined string of text
The first element of the FIND function identifies the text string you are searching for. The second part (after the first comma) identifies the text string you are referring to,
and the third part (after the second comma) identifies the starting position for your search (number of characters from furthest left)
Note that this formula would work without the starting position number in this example, as it defaults to starting at the beginning of the text string.
In plain English:
Tell me the starting position for the word "Debtors" in cell C18
If the text cannot be found, Excel will return the #VALUE! error: #VALUE! =FIND("debtors", C18)
Note that an error is returned in the example above because the FIND function is case sensitive, and "debtors" in the formula does not have a capital D
SEARCH also allows us to use wildcards (* and ?), whereas FIND does not:
Wildcards:
* (asterisk) - all
? (question mark) - any character (enter ? for each single wildcard character)
debt* 26 =SEARCH(C37, C18)
de??ors 26 =SEARCH(C38, C18)
As you can see, SEARCH works in this instance where FIND does not
It's also possible to simply return the position of an individual character. In the example below, we're returning the position of the "-" character only:
When we're looking for a single character, the limitations of FIND vs SEARCH do not matter.
We could determine the text we are looking for and the starting position for the search through a cell reference:
Note that in the example above we used a starting position of 1. See what happens if you make it 15. What about if it is 30?
What you may have noticed is that the starting position does very little in the example above (unless you enter a number greater than 26).
If the text you were seeking to locate within your overall text string was repeated one or more times, and for some reason you wanted to ignore one of the first instances, then it would be of more use:
In the example above, the starting position entry of 21 means that the resulting formula output is showing us the location of the second instance of "Debtors"
Sometimes we might just use FIND as a flag to indicate whether a particular word or text string is part of a longer string:
In the example below, we can see how FIND can be used alongside some of the functions we've been looking at so far to add a layer of flexibility.
Let's say we want to extract just the reference number from the text string below (the number sequence before the name), but the reference number varies in length:
The first thing you should be looking out for in a situation like this is some element within the text string series that is consistent. In this example it looks like the "_" character consistently follows the reference number we want to extract.
Because of this, we can use the "_" character as part of our FIND logic:
We can then easily remove the "Ref: " section if we need to, in a variety of ways:
#NAME? #NAME?
#NAME? #NAME?
#NAME? #NAME?
#NAME? #NAME?
#NAME? #NAME?
Remember, what we're trying to do here is just pull out the day reference at the end of the text string. The challenge we face is that the day reference varies in terms of its text string length
What we could do with FIND is identify the position of the last instance of the "-" character, and add one to the position to ignore the final space
This is where these functions become so powerful - it's not so much their basic capabilities, it's the way you apply them and bring them together.
Bringing them together doesn't have to be done in one cell. You can break your logic down into multiple steps.
What if we wanted to extract just the Month text and number from the centre of the text string?
We'll come back to that later (after we've introduced another function…)
Exercise
1 Use the FIND function to return the position of the first name of the customer contact
Now use FIND to return the position of the second "-" character in the same data set above
2 Use the FIND function, and any other functions we've covered so far, to extract the various month references from the first part of the text strings below ("12" in the last row refers to month 12)
Exercise Solution
Use the FIND function to return the position of the first name of the customer contact
Now use FIND to return the position of the second "-" character in the same data set above
17 {=FIND("-", C168:C171, 6)}
17
17
17
2 Use the FIND function, and any other functions we've covered so far, to extract the various month references from the first part of the text strings below ("12" in the last row refers to month 12)
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The MID function
Key points
The MID function allows you to extract a particular number of characters from a text string, starting from a position within the string that you identify
This is our base text string which we are going to reference using the MID function
The first element of the MID function identifies the text string, the second part (after the first comma) identifies the starting position (the number of characters from the left),
and the third part (after the second comma) identifies the number of characters to be returned
In plain English:
Return 7 characters from cell C17 starting at character 15
In the example above, the text string is linked through from another cell. In addition we can identify the starting position and the number of characters to extract through a cell reference:
Application
Sarah has some PO data that she needs some help with. The 9 characters after the first "-" are the location references
This works well enough when the text strings are consistent in structure and length. But what if they're not?
Let's say we want to pull the company letter reference from the centre of the text string below:
We can't use a hardcoded starting reference with MID because the initial code length varies.
Let's turn back to our ongoing text string challenge. This time, we want to extract the Month text and number from the centre of the text string.
This is challenging because the length of the Month text strings vary:
2018 - Month 3 - 3rd Month 3 {=MID(C63:C69, 8, FIND("-", C63:C69, 8)-FIND("-", C63:C69) - 2)}
2018 - Month 5 - 9th Month 5 In this example we're using FIND twice within a MID function to dynamically identify the positions of the two "-" characters
2018 - Month 7 - 12th Month 7
2018 - Month 11 - 21st Month 11
2019 - Month 1 - 7th Month 1
2020 - Month 12 - 15th Month 12
2021 - Month 8 - 20th Month 8
Note that in the formula above for Step 1, we've included a hardcoded 8 to start the FIND process beyond the first instance of the "-" character
This isn't a fully dynamic solution, and it only works like this if we are absolutely certain the structure of the data will never change significantly
A better solution, a more "future-proofed" solution, would be to use another function to dynamically locate the first "-" character and use that position as the starting point for the FIND function
You'll see this approach being used in the exercise solution below - we just wanted to highlight this here for now
This is stepping up a bit into "modern Excel", and we haven't covered SEQUENCE yet, but it's hard to overlook this.
Using SEQUENCE with MID provides us with an incredible, dynamic method of splitting a text string up.
Let's imagine the number below is a log of individual moves made by a player on a board game, using one die:
364534264526453
By nesting SEQUENCE within MID, we can create a dynamic array output that splits each number into individual cells:
Those of you familiar with TEXTJOIN will know that we could then rejoin this sequence back into one cell with new delimiters (if we wanted to):
This is just the very tip of the iceburg with dynamic array functions! We just want to wet your appetite for now…
Exercise
1 Use the MID function to extract the 9 digit invoice number reference from the centre of the text strings below
2 Use any functions we have covered so far to extract the numbers between the ### symbols in the centre of the text strings below:
Exercise Solution
1 Use the MID function to extract the 9 digit invoice number reference from the centre of the text strings below
2 Use any functions we have covered so far to extract the numbers between the ### symbols in the centre of the text strings below:
34 {=FIND("###", C155:C158) + 3}
33
32
32
Step 3: Calculate the number of characters between the end of the first string and the start of the second string
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The SUBSTITUTE function
Key points
The SUBSTITUTE function allows you to replace text from within a text string.
You would use the SUBSTITUTE function over the REPLACE function when you want to replace text based on its content rather than its position.
You can optionally specify instances of the text identified that should be substituted.
Application
Let's say we want to remove the # symbols from the text string below:
You may alternatively prefer to set the adjustments up in separate, clearly visible input cells (although this could be overkill in certain situations):
Note: sometimes a simple Find & Replace can be a much quicker and simpler solution. The downside is that you lose the audit trail of your adjustments, and the adjustments will have to be repeated time after time if the source data changes
Here's a pretty neat way SUBSTITUTE can be used with LET to count the number of times a specific character is found within a text string:
Let's say we want to count the "-" characters below:
This formula works by removing the number of instances the character occurs from the second LEN calculation, and then subtracting that number from the original LEN calculation
The difference between the two LEN calculations will always be the number of instances the character you're looking for occurs
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 1
Please extract the individual elements from the text below using only the text functions we have covered so far i
Hint: use as many columns to the right as you like to separate out any elements of your formulas
The order of the data is as follows: First Name, Second Name, Customer Reference, Order Number, Product Re
Please extract the account number and description from the text below using only the text functions we have cov
using only the text functions we have covered so far in this workbook:
************ 1100015 21
Description
Solution 1
Please extract the individual elements from the text below using only the text functions we have covered so far i
Hint: use as many columns to the right as you like to separate out any elements of your formulas
The order of the data is as follows: First Name, Second Name, Customer Reference, Order Number, Product Re
Please extract the account number and description from the text below using only the text functions we have cov
Cust Ref Order no Product Ref Length First space First Dash
456832 110044 A6052 36 5 12
455612 110045 A6852 35 5 11
6556832 120044 B6252 36 5 11
62156832 116644 D456052 40 6 12
455692 1261044 C45 41 8 18
Key points
The TEXTSPLIT function does exactly what it says it will do: it will split text, depending on some criteria and controls you manage within it
The result of your TEXTSPLIT will be an array that can span many rows or columns
For many Excel users, this is a powerful replacement or alternative to features and functions like Text-To-Columns, and LEFT, RIGHT, MID, etc
In this example TEXTSPLIT is used to separate the text before and after any "-" characters into separate columns
You may have noticed that we didn't generate all of the output results in the example above from one cell this time (which is why we have four grey fill cells)
Currently, and we say that because we suspect this may change in a future update of Excel, there is an "array of an array" blocker with array functions like TEXTSPLIT.
By this we mean that Excel expects the output shape of an array input to match that of the input array.
So let's try the solution above with a single cell array formula:
The output generated is still an array, but it's limited to the shape of the input array, which means we can't use it to split the text strings by our " - " delimiter.
There is a way around this, if you really want to use TEXTSPLIT from one cell… but it's taking us down a bit of a rabbit hole. We'll show you this now, and then stop before we get too deep.
This slightly convoluted workaround uses TEXTJOIN, and a new delimiter, to take our initial range of cell text strings and bring them together into one string (joined together with this new delimiter ";")
From there we can then use TEXTSPLIT on this new consolidated text string, and use both the row and column delimiter parameters to split the text out as we originally desired.
A successful workaround, but equally we could just stick to the alternative solution we showed you at the top of this tab and copy paste multiple individual cell formulas using TEXTSPLIT
That's what we'll be doing for the rest of this worksheet.
Now let's look at some of the variations you can set up with TEXTSPLIT
In this example, the text is split into three separate columns as TEXTSPLIT has found two "-" characters to split by
In this example, the text is split into three separate columns, but we're using two individual characters as delimiters and some curly brackets to allow TEXTSPLIT to work in this way
In this example the additional comma is used to allow us to identify the "-" character as a row delimiter instead of a column delimiter
This just means the text is split by ROW rather than by COLUMN
Here's the same outcome with the original data structured horizontally:
Jan - 144995535 - Peter H Mar - 195895049 - Sarah O Jan - 938560385 - James D Dec - 839948573 - John H
#NAME? #NAME? #NAME? #NAME?
#NAME? #NAME? #NAME? #NAME?
#NAME? #NAME? #NAME? #NAME?
In this context, "empty values" refers to the result when there are two delimiters next to each other.
In the example below, you'll see two "-" back to back. This leaves an empty space (cell highlighted in red fill) which has to be dealt with when you use TEXTSPLIT
Exercise
1Split the text string into individual Excel cell references, vertically
Note: this is a merged cell
L9;I3;E12;D10;I3;L9;I4;O4;D12;H11;E14;J8;B6;M6;J10;A6;G15;H7;M7;M13;O7;E11;J12;J2;I7;E8;M14;O9;F7;F4;E3;E15;D12;C9;J6;M10;L9;L3;M11;M2
2Split the text string into individual Excel cell references, vertically
Note: this time there is more than one character type between each cell reference
L9;I3;E12;D10;I3;L9;I4;O4;D12;H11;E14;J8;B6;M6;J10;A6;G15;H7;M7;M13;O7;E11;J12;J2;I7;E8;M14;O9;F7;F4;E3;E15;D12;C9;J6;M10;L9;L3;M11;M2
Solution
1Split the text string into individual Excel cell references, vertically
Note: this is a merged cell
L9;I3;E12;D10;I3;L9;I4;O4;D12;H11;E14;J8;B6;M6;J10;A6;G15;H7;M7;M13;O7;E11;J12;J2;I7;E8;M14;O9;F7;F4;E3;E15;D12;C9;J6;M10;L9;L3;M11;M2
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
2Split the text string into individual Excel cell references, vertically
Note: this time there is more than one character type between each cell reference
L9;I3;E12;D10;I3;L9;I4;O4;D12:H11;E14;J8;B6;M6;J10;A6;G15;H7;M7;M13-O7;E11;J12;J2;I7;E8;M14;O9;F7;F4-E3;E15;D12;C9;J6;M10;L9;L3-M11;M2
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The TEXTBEFORE & TEXTAFTER Functions
=TEXTAFTER(text,delimiter,[instance_num],[match_mode],[match_end],[if_not_found])
text - the text string that you're going to split
delimiter - the character(s) that delimit the text.
instance_num - the instance of the delimiter in text. Default is 1. [optional]
match_mode - case-sensitivity. 0 = enabled, 1 = disabled. Default is 0. [optional]
match_end - treat end of text as delimiter. 0 = disabled, 1 = enabled. Default is 0. [optional]
if_not_found - value to return when no match is found. #N/A is default. [optional]
Key points
The TEXTBEFORE function returns the text that occurs before a given substring or delimiter.
In cases where multiple delimiters appear in the text, TEXTBEFORE can return text before the nth occurrence of the delimiter.
TEXTBEFORE can also extract text that occurs before a given delimiter when counting from the end of a text string (i.e., get the text before the second to last delimiter).
TEXTBEFORE takes six arguments, but only the first two are required for the function to work: "text" provides the text to process, and "delimiter" is the substring used to split the text.
The TEXTAFTER function returns the text that occurs after a given substring or delimiter.
In cases where multiple delimiters appear in the text, TEXTAFTER can return text after the nth occurrence of the delimiter.
TEXTAFTER can also extract text after a specific delimiter when counting from the end of a text string (i.e., get text after the second to the last delimiter).
TEXTAFTER takes six arguments, but only the first two are required for the function to work: "text" provides the text to process, and "delimiter" is the substring used to split the text.
In this example TEXTBEFORE is used to separate the text before the first "-" character:
You can also reference arrays of cells with TEXTBEFORE and TEXTAFTER in the way we highlighted was an issue with TEXTSPLIT.
Why? Because the input array (range) and output array will always be the same shape (we don't lose any data we don't want to lose)
Now let's look at some of the variations you can set up with TEXTBEFORE & TEXTAFTER
In this example we're using the TRANSPOSE function to profile our output array horizontally, still based on a dynamic array formula entered into one cell
We can use negative instance numbers to count delimiters backwards (from the end of the text string)
And finally, just as we saw with TEXTSPLIT, we can use curly brackets to include multiple delimiters at once
Ref: 338402_Tom Marshall: USA #NAME? {=_xlfn.textafter(C100:C104, {" - ",": ",". "}, -1)}
Ref: 469964402_Sharon Levet - England #NAME? In this formula, we're looking for the first instance of any of the delimiters listed, working backwards from the end of the text string
Ref: 9944738_Hannah Watts: Canada #NAME?
Ref: 338402_Philip Angle. Australia #NAME?
Ref: 338402_Pierre Grant: France #NAME?
Exercise
1 For this exercise, see if you can solve the problem we dealt with in the early function worksheets (LEFT, RIGHT, LEN, FIND, MID), using TEXTBEFORE or TEXTAFTER
You just want to extract the day text string from the right hand side of the data set below
2 Extract the full name of each individual from the data set below
Solution
1 For this exercise, see if you can solve the problem we dealt with in the early function worksheets (LEFT, RIGHT, LEN, FIND, MID), using TEXTBEFORE or TEXTAFTER
You just want to extract the day text string from the right hand side of the data set below
2 Extract the full name of each individual from the data set below
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 2
1 The data set below includes student names, test scores, and an overall comment.
Split the data up into relevant columns
1 The data set below includes student names, test scores, and an overall comment.
Split the data up into relevant columns
Key points
XLOOKUP is a much-improved version of "older" lookup functions like VLOOKUP, HLOOKUP and INDEX MATCH
The function includes an optional argument for what to return if no match is found. This removes the need for separate error management functions.
As with other reference functions, we are able to choose an exact or approximate match using the match_mode argument.
XLOOKUP also includes the additional feature of defining whether the search is performed top to bottom or bottom to top using the search_mode argument.
The function can take advantage of the dynamic array engine, returning multiple entries for one formula.
The XLOOKUP function only works with a 365 licence and with Excel 2021. This raises a significant compatibility risk which you must consider if you intend to share your modelling work with other stakeholders.
In our opinion this is a much improved method for mapping tables of data, with the one (significant) caveat of compatibility risk.
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Lamb Pies from the product table
Let's take a closer look at the structure of the arguments in the formula
This time Sarah's list of products and their prices are in a table structured in rows:
We can still use XLOOKUP to build a dynamic formula that will pull out the sales value for the product selected
In plain English:
Return the price of Lamb Pie from the product table
What happens if the product we are looking for is not in the product table?
Let's see what happens if the product we are looking for is not in the product table, and how we can use the [not_found] argument to improve the result:
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Apple Pie from the product table
As Apple Pie is not in the product table, XLOOKUP returns the error value #N/A
Before the introduction of XLOOKUP, we'd typically manage this error using the IFERROR function:
We can keep the two functions separate by referring to the result value: Not found =IFERROR(G76,"Not found")
We need to use IFERROR with care as it handles all errors in the same way and could mask a more serious #REF! or #VALUE! error.
So let's now use the [not_found] argument within XLOOKUP to improve the result:
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Apple Pie from the product table. If the result is not found then return "Not found".
As with MATCH and other LOOKUP functions, it is possible to perform different types of match:
The optional match_mode argument defines how the match should be performed:
Description Match_mode
Exact match 0 (default)
Exact match or next lower -1
Exact match or next higher 1
Wildcard match 2
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Lamb Pie from the product table. If the result is not found then return "Not found". Only return an exact match
We would like to use the table below to assign an age to an age category
Age Category
0 0-9
10 10-19
20 20-29
30 30-39
40 40-59
60 60+
In plain English:
Return the category for the age entered. This is achieved by searching from the bottom and finding the nearest lowest number to the age value entered.
We would like to use the table below to assign an age to an age category
Age Category
100 60-100
60 40-59
40 30-39
30 20-29
20 10-19
10 0-9
In plain English:
Return the category for the age entered. This is achieved by searching from the top and finding the nearest highest number to the age value entered.
4. Wildcard match
* (asterisk) - all
? (question mark) - any character (enter ? for each single wildcard character)
Starts with Ha: Ha* 131 =_xlfn.xlookup(D176, C167:C172, D167:D172, "Not found", 2)
End with Wood *Wood 131 =_xlfn.xlookup(D178, C167:C172, D167:D172, "Not found", 2)
Using the ?: Ha?es Wood 131 =_xlfn.xlookup(D182, C167:C172, D167:D172, "Not found", 2)
The search_mode argument lets us choose the direction of the search - i.e. top to bottom (default) or bottom to top.
Product Price
Chicken Pie £ 5.00
Lamb Pie £ 3.00
Chicken Pie £ 10.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Chicken Pie from the product table. If the result is not found then return "Not found". Only return an exact match. Start the search from the top.
Product Price
Chicken Pie £ 5.00
Lamb Pie £ 3.00
Chicken Pie £ 10.00
Vegetarian Pie £ 3.25
Pork Pie £ 3.15
In plain English:
Return the price of Chicken Pie from the product table. If the result is not found then return "Not found". Only return an exact match. Start the search from the bottom.
Note: if there are multiple matches, XLOOKUP will return the first it finds (depending on whether you have set the search mode to Top to Bottom or Bottom to Top)
We can also leverage the new Dynamic Array functionality with XLOOKUP.
Chicken Pie
Dynamic Version 2 - Returning result from a single lookup range for multiple input values
If we instead use a range for our lookup values, we'll see the resulting formula spill in a different way:
Product Price
Chicken Pie £ 5.00
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Chicken Pie
Lamb Pie The formula is only
entered in the first
cell
Price
#NAME? {=_xlfn.xlookup(C250:C251,C246:C248,D246:D248,"Not found")}
#NAME?
The formula automatically
extends down to a second
row
Attempt at Dynamic Version 3: Multiple inputs and output ranges (note - it doesn't work!)
Chicken Pie
Lamb Pie
We may have expected the
formula to spill here as well,
Price Quantity Produ Quantity Sold but Excel doesn't allow this (at
#NAME? the moment) {=_xlfn.xlookup(C266:C267,C262:C264,D262:F264,"Not found")}
#NAME?
This time we're using a
range for both the input
values and the lookup
ranges.
The result is still a dynamic
array, but it's only extending
down (not across)
This is a theme we'll come back to. For now, just note that there are limitations when it comes to leaning on the new array features in Excel
If we try to set up a formula like this with both row and columns ranges as inputs, Excel will only return one element of them
We believe this may change in the future
Application
Sarah has some sales data from her sales till system. She also has some reference data that includes each product's price, cost and category.
Sarah would like to combine this data together to create one single data set that she can use for reporting
Market date Product Quantity Sold Product Unit Price Unit Cost Pie Category
02/01/18 Chicken Pies 171 Chicken Pies £ 8.00 £ 1.20 Meat Pie
02/01/18 Lamb Pies 72 Lamb Pies £ 8.50 £ 1.95 Meat Pie
02/01/18 Vegetarian Pies 29 Vegetarian Pie £ 7.50 £ 1.00 Veggie Pie
04/01/18 Chicken Pies 178
04/01/18 Lamb Pies 72
04/01/18 Vegetarian Pies 24
06/01/18 Chicken Pies 175
06/01/18 Lamb Pies 67
06/01/18 Vegetarian Pies 28
09/01/18 Chicken Pies 179
09/01/18 Lamb Pies 72
Market date Product Quantity SoldUnit Price Unit Cost Pie Category Unit Price Unit Cost Pie Category
02/01/18 Chicken Pies 171 #NAME? #NAME? #NAME? £ 8.00 £ 1.20 Meat Pie
02/01/18 Lamb Pies 72 #NAME? #NAME? #NAME? £ 8.50 £ 1.95 Meat Pie
02/01/18 Vegetarian Pies 29 #NAME? #NAME? #NAME? £ 7.50 £ 1.00 Veggie Pie
04/01/18 Chicken Pies 178 #NAME? #NAME? #NAME? £ 8.00 £ 1.20 Meat Pie
04/01/18 Lamb Pies 72 #NAME? #NAME? #NAME? £ 8.50 £ 1.95 Meat Pie
04/01/18 Vegetarian Pies 24 #NAME? #NAME? #NAME? £ 7.50 £ 1.00 Veggie Pie
06/01/18 Chicken Pies 175 #NAME? #NAME? #NAME? £ 8.00 £ 1.20 Meat Pie
06/01/18 Lamb Pies 67 #NAME? #NAME? #NAME? £ 8.50 £ 1.95 Meat Pie
06/01/18 Vegetarian Pies 28 #NAME? #NAME? #NAME? £ 7.50 £ 1.00 Veggie Pie
09/01/18 Chicken Pies 179 #NAME? #NAME? #NAME? £ 8.00 £ 1.20 Meat Pie
09/01/18 Lamb Pies 72 #NAME? #NAME? #NAME? £ 8.50 £ 1.95 Meat Pie
2D Lookups
If you're familiar with INDEX MATCH (which we'll cover next), you may be familiar with the INDEX MATCH MATCH approach to perform a two dimensional lookup.
The good news is you can do exactly the same thing with an XLOOKUP nested within another XLOOKUP:
Input 1 Tom
Input 2 Mar
Result: #NAME? {=_xlfn.xlookup(D334, C329:C331, _xlfn.xlookup(D335, D328:I328, D329:I331))}
Once you get used to this nested structure you'll find it's even easier to use than INDEX MATCH MATCH)
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 3
Sarah has downloaded some data from her stock system:
Unit Of Measure
Product Ref Description Price Cost UoM Max Stock
SKU0001 Chicken Pie £ 8.00 £ 1.20 Each 300
SKU0002 Lamb Pie £ 8.50 £ 1.95 Each 150
SKU0003 Vegetarian Pie £ 7.50 £ 1.00 Each 205
SKU0004 Pork pie £ 8.00 £ 1.45 Each 450
1. Please use the XLOOKUP function to find the Cost of the product listed below
SKU0002
2. Please use the XLOOKUP function to find the Description for the product listed below
SKU0003
3. Please use the XLOOKUP function to find the Max Stock for the product listed below
Lamb Pie
4. Please use the XLOOKUP function to create a dynamic lookup that can return the appropriate data point based on the two dropdowns below
Max Stock
Pork pie
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Solution 3
Sarah has downloaded some data from her stock system:
Unit Of Measure
Product Ref Description Price Cost UoM Max Stock
SKU0001 Chicken Pie £ 8.00 £ 1.20 Each 300
SKU0002 Lamb Pie £ 8.50 £ 1.95 Each 150
SKU0003 Vegetarian Pie £ 7.50 £ 1.00 Each 205
SKU0004 Pork pie £ 8.00 £ 1.45 Each 450
1. Please use the XLOOKUP function to find the Cost of the product below
SKU0002
1.95
2. Please use the XLOOKUP function to find the Description for the product below
SKU0003
#NAME?
3. Please use the XLOOKUP function to find the Max Stock for the product below
Lamb Pie
150
4. Please use the XLOOKUP function to create a dynamic lookup that can return the appropriate data point based on the two dropdowns below
Max Stock
Pork pie
#NAME?
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 4
1) Sarah has downloaded some customer postcodes from her CRM system
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Customer: Customer 2
2) Sarah would like to pull sales values from the table below:
Customer 946
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Solution 4
1) Sarah has downloaded some customer postcodes from her CRM system
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Customer: Customer 2
Use the XLOOKUP function to return the postcode for customer 2: #NAME?
2) Sarah would like to pull sales values from the table below:
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 5
Sarah has some sales data from her sales till system. She also has some reference data on the Inputs tab that in
Sarah would like to enrich the table of data on this tab with the reference data on the Inputs tab to create one sin
The column headers describe what data you are being asked to create. Use XLOOKUP to enrich the data as req
Are you able to take advantage of Dynamic Array functionality so that you only have to enter a formula in column
Sarah has some sales data from her sales till system. She also has some reference data on the Inputs tab that inclu
Sarah would like to enrich the table of data on this tab with the reference data on the Inputs tab to create one single
The column headers describe what data you are being asked to create. Use XLOOKUP to enrich the data as requir
Are you able to take advantage of Dynamic Array functionality so that you only have to enter a formula in column G
array - The range of cells that you want to return a value from
row_num - The position number of the row that you want to return a value for
col_num - The position number of the column that you want to return a value for
Key points
The INDEX function allows you to return a value from a given position within a range
It is one of the most widely used functions in financial modelling due to its flexibility and potential power (especially when used in conjunction with the MATCH function)
You can use INDEX to return individual values or entire rows and columns
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork pie £ 3.15
We can use the INDEX function to identify the range of values we want to choose from, and we manually enter the position of the specific value we want to return:
In plain English:
Return the third item from the range C19 to C22
Instead of manually entering the position of the value we want to return, we can refer to another cell where the position can be entered:
Index can be used for ranges across rows or columns. Let's look at the same table of data, this time set across a number of columns:
Column 3 This time let's reference row 41: £ 3.25 {=INDEX(D41:G41, D48)}
Application
Case ID 1 2 3 4 5
Case Worst Case Mid - 1 Mid - 2 Mid -3 Best Case
Sales value £20,000 £30,000 £40,000 £45,000 £50,000
Live Scenario 5
Like a lot of companies, Sarah's business runs a financial year from April to March
Sarah could use INDEX to pick the fourth month in her financial year:
Apr-18
May-18
Jun-18
Jul-18
Aug-18
Sep-18
Oct-18
Nov-18
Dec-18
Jan-19
Feb-19
Mar-19
4 Jul-18 {=INDEX(C69:C80,C82)}
If Sarah wanted to pick the third day from a list of days of the week she could also use INDEX:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
3 Wednesday =INDEX(C87:C93,C95)
One of the best use cases for INDEX is to efficiently bring additional data through into modelling periods:
Imagine we have this list of inputs in our Inputs tab within a financial model:
Seasonality
Jan 140.00%
Feb 120.00%
Mar 90.00%
Apr 70.00%
May 60.00%
Jun 90.00%
Jul 150.00%
Aug 190.00%
Sep 150.00%
Oct 110.00%
Nov 80.00%
Dec 90.00%
And on the right we have an extract of some of the timeline data from our model:
Model Period 1 2 3 4 5 6 7 8 9 10 11 12 13
Period Start Date 1/1/2024 2/1/2024 3/1/2024 4/1/2024 5/1/2024 6/1/2024 7/1/2024 8/1/2024 9/1/2024 10/1/2024 11/1/2024 12/1/2024 1/1/2025
Period End Date 1/31/2024 2/29/2024 3/31/2024 4/30/2024 5/31/2024 6/30/2024 7/31/2024 8/31/2024 9/30/2024 10/31/2024 11/30/2024 12/31/2024 1/31/2025
We can use the natural order of the INDEX with months listed in order like this:
Month No. 1 2 3 4 5 6 7 8 9 10 11 12 1
Seasonality 140.00% 120.00% 90.00% 70.00% 60.00% 90.00% 150.00% 190.00% 150.00% 110.00% 80.00% 90.00% 140.00%
This successfully pulls through the seasonality data into a horizontal structure, without the need for any additional lookup references
Note: this approach doesn't have to align to months of the year. Essentially you can use INDEX like this to extract data from a range in order, so long as the numerical lookup number aligns properly to your lookup table
Exercises
Customer Postcode
Customer 1 SO22 6JD
Customer 2 PD32 9WE
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Use the INDEX function along with a separate input cell to allow a user to change the postcode that is generated:
Customer No. 2
INDEX Function:
Exercise Solutions
Customer Postcode
Customer 1 SO22 6JD
Customer 2 PD32 9WE
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Use the INDEX function along with a separate input cell to allow a user to change the postcode that is generated:
Customer No. 2
INDEX Function: PD32 9WE
Limitations
Use the Index function to generate the 2017 sales for customer 946:
Index Function:
For large lists it can be difficult to identify the position of the value you want to return.
This is why INDEX and MATCH tends to be used as a pair for larger data set lookups…
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The MATCH function
Key points
The MATCH function allows you to return the relative position of a chosen value from within a selected range.
MATCH will return a number which represents the position of the chosen value within the range.
When used in conjunction with INDEX it is extremely powerful, but let's just take the function on its own for now.
MATCH returns a #N/A error if no match is found.
This time, we're going to use MATCH to return the position of "Lamb Pie" within the selected range
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork pie £ 3.15
In plain English:
What is the position of "Lamb Pie" in the range C22 to C25
Match type
The zero at the end of the function (the match type) means we have searched for the position of an exact match for "Lamb Pie"
Match type
These are the match type options available to you within the MATCH function:
0 MATCH finds the first value that is an exact match to the lookup value.
1 (or omitted) MATCH finds the largest value that is less than or equal to the lookup value. The values in the range must be placed in ascending order for this to work.
-1 MATCH finds the smallest value that is more than or equal to the lookup value. The values in the range must be placed in descending order for this to work.
Note: Set match type to zero (0) if you need an exact match. The default setting of 1 can cause MATCH to return results that appears to be working but are in fact incorrect.
VALUE VALUE
- 2,000
250 1,750
500 1,500
750 1,250
1,000 1,000
1,250 750
1,500 500
1,750 250
2,000 -
Largest value that is less than or equal to the lookup value, enter 1 2 =MATCH(E68, C58:C66, 1)
Smallest value that is more than or equal to the lookup value, enter -1 7 =MATCH(E68, E58:E66, -1)
Application
Most of the time we will be using MATCH together with other functions such as INDEX.
In isolation, MATCH can be used to quickly determine whether or not an item is present in a list or not. For example:
Sarah would like to find out whether two postcodes (EC1A 1BB and BS4 3NF) exist in a table she has downloaded
Postcode
SO22 6JD
YT49 8DD
PQ92 8BX
PD32 9WE
EC1A 1BB
W1A 0AX
M1 1AE
B33 8TH
CR2 6XH
DN55 1PT
Sarah now knows that EC1A 1BB is in the list and BS4 3NF is not. COUNTIFS could also be used to perform this check.
Exercises
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Use the MATCH function to return the relative position of customer 2 within the range above:
Customer:
Exercise Solutions
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Use the MATCH function to return the relative position of customer 2 within the range above:
Customer: Customer 2 4
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Combining INDEX and MATCH
Key points
Used together INDEX and MATCH offer an extremely powerful method for looking up and returning specific items from a table of data.
It is more robust than HLOOKUP or VLOOKUP and we advise that it should be used instead of these functions.
If we turn to our table of product sales data again, we can use INDEX and MATCH together to build a dynamic formula that will pull out the sales value for the product you choose in cell B20
Try choosing a different product and see what happens to the price in cell G20
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork pie £ 3.15
In plain English:
INDEX and MATCH return the price of Lamb Pie from the table
Let's look at this broken down into its two elements, starting with the MATCH:
What is the position of Lamb Pie in the range C15 to C18 2 =MATCH(C20, C15:C18, 0)
Return the item in position 2 from the range D15 to D18 £ 3.00 {=INDEX(D15:D18, G28)}
We recommend splitting the MATCH element out from the INDEX when it makes sense to do so, as this improves the clarity and simplicity of your model
Application
Sarah has some sales data from her sales till system. She also has some reference data that includes each product's price, cost and category.
Sarah would like to combine this data together to create one single data set that she can use for reporting
Market date Product Quantity Sold Product Unit Price Unit Cost Pie Category
02/01/18 Chicken Pies 171 Chicken Pies £ 8.00 £ 1.20 Meat Pie
02/01/18 Lamb Pies 72 Lamb Pies £ 8.50 £ 1.95 Meat Pie
02/01/18 Vegetarian Pies 29 Vegetarian Pies £ 7.50 £ 1.00 Veggie Pie
04/01/18 Chicken Pies 178
04/01/18 Lamb Pies 72
04/01/18 Vegetarian Pies 24
06/01/18 Chicken Pies 175
06/01/18 Lamb Pies 67
06/01/18 Vegetarian Pies 28
09/01/18 Chicken Pies 179
09/01/18 Lamb Pies 72
Market date Product Quantity Sold Product Match Pie Category Unit Price Unit Cost Pie Category Unit Price Unit Cost
02/01/18 Chicken Pies 171 1 Meat Pie £ 8.00 £ 1.20 Meat Pie £ 8.00 £ 1.20
02/01/18 Lamb Pies 72 2 Meat Pie £ 8.50 £ 1.95 Meat Pie £ 8.50 £ 1.95
02/01/18 Vegetarian Pies 29 3 Veggie Pie £ 7.50 £ 1.00 Veggie Pie £ 7.50 £ 1.00
04/01/18 Chicken Pies 178 1 Meat Pie £ 8.00 £ 1.20 Meat Pie £ 8.00 £ 1.20
04/01/18 Lamb Pies 72 2 Meat Pie £ 8.50 £ 1.95 Meat Pie £ 8.50 £ 1.95
04/01/18 Vegetarian Pies 24 3 Veggie Pie £ 7.50 £ 1.00 Veggie Pie £ 7.50 £ 1.00
06/01/18 Chicken Pies 175 1 Meat Pie £ 8.00 £ 1.20 Meat Pie £ 8.00 £ 1.20
06/01/18 Lamb Pies 67 2 Meat Pie £ 8.50 £ 1.95 Meat Pie £ 8.50 £ 1.95
06/01/18 Vegetarian Pies 28 3 Veggie Pie £ 7.50 £ 1.00 Veggie Pie £ 7.50 £ 1.00
09/01/18 Chicken Pies 179 1 Meat Pie £ 8.00 £ 1.20 Meat Pie £ 8.00 £ 1.20
09/01/18 Lamb Pies 72 2 Meat Pie £ 8.50 £ 1.95 Meat Pie £ 8.50 £ 1.95
Note how the product match is performed just once in its own column and the three INDEX functions are then kept nice and simple
Compare this to the INDEX MATCH formulas in columns K, L and M
Exercises
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Use the Match and INDEX functions separately to return the relative position of customer 2 within the range above:
Customer: Customer 2
Match Function:
Index Function
Use the Index and Match functions to generate the 2017 sales for customer 946:
Exercise Solutions
Customer Postcode
Customer 1 SO22 6JD
Customer 3 YT49 8DD
Customer 4 PQ92 8BX
Customer 2 PD32 9WE
Use the Match and INDEX functions separately to return the relative position of customer 2 within the range above:
Customer: Customer 2
Match Function: 4
Index Function PD32 9WE
Combine INDEX and MATCH to perform the same action PD32 9WE
Use the Index and Match functions to generate the 2017 sales for customer 946:
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The INDEX function - using two dimensions
Key points
The INDEX function can also return a value from within a two dimensional range, using a defined row and column position.
This essentially allows us to refer to tables of data rather than a single row or column range
Sarah has some sales quantity data from her till system. We can use INDEX to return a value from the data table:
Rather than pointing INDEX at a single row or column range, we are now going to point it at the range D18 to F21:
60 =INDEX(D18:F21, 2, 3)
In plain English:
Return the value from the cell that is in the second row and third column in the range D18 to F21
Just as we saw on the INDEX tab, instead of manually entering the position of the value we want to return, we can refer to other cells where the position can be entered:
Row 0
Column 3
30 {=INDEX(D18:F21,D33,D34)}
60
Of course it would be much more useful if we could make t 30
Let's see how we can combine a 2D INDEX with the MATCH 20
We can also use 0 to return the whole input range as an array instead of identifying specific rows and / or columns :
20 25 30 {=INDEX(D18:F21, 0, 0)}
70 10 60
40 35 30
50 40 20
25 {=INDEX(D18:F21, 0, 2)}
10
35
40
#NAME? {=_xlfn.choosecols(D18:F21,2)}
#NAME?
#NAME?
#NAME?
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Combining INDEX with two MATCH functions
Key points
We have already seen INDEX and MATCH come together to create a referencing tool that is very powerful, and widely used in financial models.
We can actually take this a step further, using MATCH twice to turn the 2D INDEX formula into something even more dynamic.
In most instances a simple one way INDEX MATCH is sufficient to solve a problem. But if you do need to dynamically reference both rows and columns then INDEX MATCH MATCH offers a way forward for you.
Now we need to use MATCH twice within the INDEX function to reference both the product range and the month range
Lamb Pie January 70 =INDEX($D$15:$F$18, MATCH(C23, $C$15:$C$18, 0), MATCH(D23, $D$14:$F$14, 0))
Both MATCH functions required an exact match to work, so you see the "0" as the final element of both functions in the formula above
In plain English:
Return the quantity of Lamb Pie sold in January from the table range refered to
This is now quite a long and less straight-forward formula to follow, so let's pull it apart by separating the MATCH elements out from the INDEX:
Exercise
Have a go at creating the same formulas you have just seen above in the grey cells below:
Solution
Have a go at creating the same formulas you have just seen above in the grey cells below:
Note: this is exactly what the nested XLOOKUP allowed us to do. It's still good to know INDEX MATCH though as you will, for some time yet we suspect, face issues of backwards compatibility (people you deal with have old versions of Excel that don't recognis
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 6
Sarah has some sales data from her sales till system. She also has some reference data on the Inputs_2 tab that inc
Sarah would like to enrich the table of data on this tab with the reference data on the Inputs_2 tab to create one sing
The column headers describe what data you being asked to create. INDEX and MATCH to enrich the data as requir
Sarah has some sales data from her sales till system. She also has some reference data on the Inputs_2 tab that inc
Sarah would like to enrich the table of data on this tab with the reference data on the Inputs_2 tab to create one sing
The column headers describe what data you being asked to create. INDEX and MATCH to enrich the data as requir
How does this compare to using XLOOKUP?
Key points
The SUMIFS function sums the values in a range that meet a specified criteria, or set of criteria.
This function is not compatible with Excel 2003 or earlier versions.
We advise that you use SUMIFS over SUMIF in all instances (even when you have just one criteria). The order of function elements switches for SUMIF, and this can be confusing if you use both within a model.
Rather than calculating the total quantity of pies sold, Sarah would like to know the total sales for a specific month:
We can use the SUMIFS function with a single criteria range for the month:
Let's break the formula above down into its key elements
sum_range This is the range that contains the numbers that you want to sum up. In this case this is the range for the quantity sold in $F$23:$F$76
criteria_range1 This is the first range that contains the criteria that you want the sum calculation to be driven by. In this case this is the month range $C$23:$C$76
criteria1 This is the criteria for the first range that you want to base your sum calculation on. In this case this is month entered into cell D87
We could also list out the full results by month for Sarah:
What if Sarah wanted to see which day of the week has been best for sales:
Note that in all of the examples above the range that we want to sum remains the same - $F$23:$F$76
Additionally, it's worth noting that all of these SUMIFS solutions can be set up with ranged lookup inputs (and spilled array outputs) as well:
You're going to see models, and modellers, using both the static and new dynamic approaches for a while yet, so it's worth remembering both.
What if Sarah would like to know the total sales for chicken pies on a Tuesday?
We now need to build a formula using SUMIFS with two criteria rather than just one:
Tuesday
Chicken Pies 4,576 =SUMIFS($F$23:$F$76, $D$23:$D$76, D167, $E$23:$E$76, D168)
Let's break the formula above down into its key elements
sum_range This is the range that contains the numbers that you want to sum up. In this case this is the quantity sold range $F$23:$F$76
criteria_range1 This is the first range that contains the criteria you want your sum calculation to be driven by. In this case this is the day of week range $D$23:$D$76
criteria1 This is the criteria for the first range that you want to base your sum calculation on. In this case this is day entered into cell D137
criteria_range2 This is the second range that contains the criteria you want your sum calculation to be driven by. In this case this is the product range $E$23:$E$76
criteria2 This is the criteria for the second range that you want to base your sum calculation on. In this case this is product entered into cell D138
It would be really useful to build out a table for Sarah so that she can see the sales by day and by product.
Note that the use of the $ signs to fix column and row references are important here if you want to copy and paste the formula from the top left to the rest of the table area.
What if Sarah would like to know the total sales for chicken pies on a Tuesday in February?
We now need to build a formula using SUMIFS with three criteria. We follow exactly the same logic we have implemented so far:
Tuesday
Chicken Pies
Feb 685 =SUMIFS($F$23:$F$76, $D$23:$D$76, D198, $E$23:$E$76, D199, $C$23:$C$76, D200)
Let's break the formula above down into its key elements
sum_range This is the range that contains the numbers that you want to sum up. In this case this is the quantity sold range $F$23:$F$76
criteria_range1 This is the first range that contains the criteria you want your sum calculation to be driven by. In this case this is the day of week range $D$23:$D$76
criteria1 This is the criteria for the first range that you want to base your sum calculation on. In this case this is day entered into cell D168
criteria_range2 This is the second range that contains the criteria you want your sum calculation to be driven by. In this case this is the product range $E$23:$E$76
criteria2 This is the criteria for the second range that you want to base your sum calculation on. In this case this is product entered into cell D169
criteria_range3 This is the third range that contains the criteria you want your sum calculation to be driven by. In this case this is the month range $C$23:$C$76
criteria3 This is the criteria for the third range that you want to base your sum calculation on. In this case this is month entered into cell D170
Sarah would now like to see the sales by day and by product, with a month filter:
Feb
Note that there is a drop down list available in cell D186 which holds the names of the relevant months.
This is an example of the use of Data Validation, and we will come on to look at this later in the course.
Exercise
1) Market Footfall
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
1 Saturday Grey 698
2 Tuesday Grey 758
2 Thursday Sunny 1,207
2 Saturday Rainy 694
3 Tuesday Grey 797
3 Thursday Sunny 1,035
3 Saturday Sunny 1,190
4 Tuesday Rainy 597
4 Thursday Sunny 970
4 Saturday Sunny 1,397
Week Number 4
Create a formula that returns the market footfall volume based on the relevant day, weather and week number values
Exercise Solution
1) Market Footfall
Week Number 4
Create a formula that returns the market footfall volume based on the relevant day, weather and week number values
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The COUNTIFS Function
Syntax =COUNTIFS(criteria_range1,criteria1,[criteria_range2],[criteria2]…)
Key points
The COUNTIFS function counts the number of cells in a range that meet a specified criteria, or set of criteria.
Unlike SUMIFS, this function only needs the criteria pairs (criteria range and criteria). There is no separate range to sum up.
COUNTIFS is available to users of Office 365 or Excel 2019.
We advise that you use COUNTIFS over COUNTIF in all instances (even when you have just one criteria). Although the structure of the two functions are similar, it keeps things more consistent to just apply one function at all times.
Rather than counting the overall number of entries, Sarah would like to know the number of entries for a specified month:
We can use the COUNTIFS function with a single criteria range of month:
Let's break the formula above down into its key elements
criteria_range1 This is the first range that contains the criteria you want your count calculation to be drive by. In this case this is the month range $C$22:$C$75
criteria1 This is the chosen criteria for the first range you want to base your count calculation on. In this case this is month entered into cell D86
We could also list out the full results by month for Sarah:
What if Sarah wanted to see which day has the most rows:
Note that the criteria range we are referencing changes each time:
For months we are referencing the range $C$22:$C$75
For days we are referencing the range $D$22:$D$75
For products we are referencing the range $E$22:$E$75
What if Sarah would like to know the number of entries for chicken pies sold on a Tuesday?
We now need to build a formula using COUNTIFS with two criteria rather than just one:
Tuesday
Chicken Pies 6 =COUNTIFS($D$22:$D$75, D133, $E$22:$E$75, D134)
Let's break the formula above down into its key elements
criteria_range1 This is the first range that contains the criteria you want your count calculation to be driven by. In this case this is the day of week range $D$22:$D$75
criteria1 This is the chosen criteria for the first range you want to base your count calculation on. In this case this is day entered into cell D133
criteria_range2 This is the second range that contains the criteria you want your count calculation to be driven by. In this case this is the product range $E$22:$E$75
criteria2 This is the chosen criteria for the second range you want to base your count calculation on. In this case this is product entered into cell D134
It would be really useful to build out a table for Sarah so that she can see the count by day and by product
If any entries were missing, Sarah would be able to spot the issue quickly (i.e. if one of the counts for pies on a particular day of the week was less than or more than 6)
What if Sarah would like to know the total rows for chicken pies on a Tuesday in February?
We now need to build a formula using COUNTIFS with three criteria rather than two:
Tuesday
Chicken Pies
Feb 1 =COUNTIFS($D$22:$D$75, D163, $E$22:$E$75, D164, $C$22:$C$75, D165)
Let's break the formula above down into its key elements
criteria_range1 This is the first range that contains the criteria you want your count calculation to be driven by. In this case this is the day of week range $D$22:$D$75
criteria1 This is the chosen criteria for the first range you want to base your count calculation on. In this case this is day entered into cell D163
criteria_range2 This is the second range that contains the criteria you want your count calculation to be driven by. In this case this is the product range $E$22:$E$75
criteria2 This is the chosen criteria for the second range you want to base your count calculation on. In this case this is product entered into cell D134
criteria_range3 This is the third range that contains the criteria you want your count calculation to be driven by. In this case this is the month range $C$22:$C$75
criteria3 This is the chosen criteria for the third range you want to base your count calculation on. In this case this is month entered into cell D135
Sarah would now like to see the count of entries by day and by product, with a month filter:
Feb
Exercise
1) Market Footfall
Create a formula that counts the number of entries for each day and weather combination from the table above
Try to build the formula in the top left cell of the table and copy it across the rest of the table (you need to use your $ signs carefully)
Exercise Solution
1) Market Footfall
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Footfall Sunny Grey Rainy Total
Tuesday 1 2 1 4
Thursday 3 - 1 4
Saturday 2 1 1 4
Total 6 3 3 12
Create a formula that counts the number of entries for each day and weather combination from the table above
Try to build the formula in the top left cell of the table and copy it across the rest of the table (you need to use your $ signs carefully)
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The SUMPRODUCT Function
Key points
The SUMPRODUCT function allows you to multiply arrays together
SUMPRODUCT is an incredibly powerful and versatile function, but it's usefulness has been diminished as a result of the more recent upgrades to Excel
Specifically, the evolution of Excel's array functions and capabilities means that much of what could only be achieved through the use of SUMPRODUCT (or CTRL + SHIFT + ENTER) can now be done with simple formulas like SUM
However, you'll still see modellers using SUMPRODUCT, and we still (for now at least) think it's well worth the time and effort to master
We still love it though, and think it's well worth your time to learn
Month Day of week Product Quantity Sold Product Price Total Revenue: £77,481 =SUMPRODUCT(F23:F76, G23:G76)
Jan Tuesday Chicken Pies 871 £3.50
Jan Tuesday Lamb Pies 357 £4.00 You could also achieve the same result by using an older CTRL + SHIFT + ENTER array:
Jan Tuesday Vegetarian Pies 136 £3.00 Total Revenue: £77,481 {=SUM(F23:F76 * G23:G76)}
Jan Thursday Chicken Pies 708 £3.50
Jan Thursday Lamb Pies 280 £4.00 See the curly brackets in the formula above?
Jan Thursday Vegetarian Pies 110 £3.00 That's what you get when you press CTRL + SHIFT + ENTER
Jan Saturday Chicken Pies 714 £3.50 instead of just pressing ENTER once you've built your formula
Jan Saturday Lamb Pies 291 £4.00
Jan Saturday Vegetarian Pies 111 £3.00 If you're using what we call "modern Excel", you can actually achieve the same result now with a simple SUM:
Feb Tuesday Chicken Pies 685 £3.50 Total Revenue: £77,481 {=SUM(F23:F76 * G23:G76)}
Feb Tuesday Lamb Pies 271 £4.00
Feb Tuesday Vegetarian Pies 100 £3.00 Why does SUM work when it didn't in years gone by?
Feb Thursday Chicken Pies 714 £3.50 It's because Excel now allows an array to SPILL, and therefore be picked up by other functions:
Feb Thursday Lamb Pies 291 £4.00
Feb Thursday Vegetarian Pies 100 £3.00 Total Revenue: £3,049 {=(F23:F33 * G23:G33)}
Feb Saturday Chicken Pies 720 £3.50 1428
Feb Saturday Lamb Pies 300 £4.00 408
Feb Saturday Vegetarian Pies 118 £3.00 2478
Mar Tuesday Chicken Pies 708 £3.50 1120
Mar Tuesday Lamb Pies 290 £4.00 330
Mar Tuesday Vegetarian Pies 86 £3.00 2499
Mar Thursday Chicken Pies 896 £3.50 1164
Mar Thursday Lamb Pies 357 £4.00 333
Mar Thursday Vegetarian Pies 132 £3.00 2397.5
Mar Saturday Chicken Pies 900 £3.50 1084
Mar Saturday Lamb Pies 374 £4.00
Mar Saturday Vegetarian Pies 140 £3.00 The formula above just uses a partial range of data from the data set on the left (so it fits above), but what you see there
Apr Tuesday Chicken Pies 700 £3.50 is the spilled array results of the formula we've been using so far without any function bolted on at the front.
Apr Tuesday Lamb Pies 283 £4.00 Put a simple SUM upfront and it'll sum all of those spilled values in the array
Apr Tuesday Vegetarian Pies 100 £3.00
Apr Thursday Chicken Pies 718 £3.50 For the sake of completeness, and on the assumption that you may well still come across models with SUMPRODUCT,
Apr Thursday Lamb Pies 295 £4.00 let's pretend we're using a version of Excel that doesn't allow you to pick up spilled arrays for the remainder of this worksheet.
Apr Thursday Vegetarian Pies 106 £3.00
Apr Saturday Chicken Pies 720 £3.50
Apr Saturday Lamb Pies 300 £4.00
Apr Saturday Vegetarian Pies 118 £3.00
May Tuesday Chicken Pies 892 £3.50
May Tuesday Lamb Pies 357 £4.00
May Tuesday Vegetarian Pies 128 £3.00
May Thursday Chicken Pies 894 £3.50
May Thursday Lamb Pies 359 £4.00
May Thursday Vegetarian Pies 131 £3.00
May Saturday Chicken Pies 720 £3.50
May Saturday Lamb Pies 300 £4.00
May Saturday Vegetarian Pies 112 £3.00
Jun Tuesday Chicken Pies 720 £3.50
Jun Tuesday Lamb Pies 283 £4.00
Jun Tuesday Vegetarian Pies 95 £3.00
Jun Thursday Chicken Pies 720 £3.50
Jun Thursday Lamb Pies 292 £4.00
Jun Thursday Vegetarian Pies 109 £3.00
Jun Saturday Chicken Pies 900 £3.50
Jun Saturday Lamb Pies 370 £4.00
Jun Saturday Vegetarian Pies 145 £3.00
Month Day of week Product Quantity Produced Quantity Sold Product Price
Jan Tuesday Chicken Pies 900 896 £3.50
Jan Tuesday Lamb Pies 400 365 £4.00 SUMPRODUCT can perform advanced COUNTS:
Jan Tuesday Vegetarian Pies 150 136 £3.00
Jan Thursday Chicken Pies 708 600 £3.50 Count the number of times any individual product sells out 15
Jan Thursday Lamb Pies 280 279 £4.00
Jan Thursday Vegetarian Pies 110 110 £3.00 Count the number of times each product below sells out:
Jan Saturday Chicken Pies 714 711 £3.50 Chicken Pies 4
Jan Saturday Lamb Pies 291 291 £4.00 Lamb Pies 5
Jan Saturday Vegetarian Pies 111 95 £3.00 Vegetarian Pies 6
Feb Tuesday Chicken Pies 685 685 £3.50
Feb Tuesday Lamb Pies 271 271 £4.00
Feb Tuesday Vegetarian Pies 100 100 £3.00 Calculate the revenue earned by product for the day listed below:
Feb Thursday Chicken Pies 714 701 £3.50
Feb Thursday Lamb Pies 291 280 £4.00 Tuesday
Feb Thursday Vegetarian Pies 100 60 £3.00 Chicken Pies 16,027
Feb Saturday Chicken Pies 720 720 £3.50 Lamb Pies 7,324
Feb Saturday Lamb Pies 300 300 £4.00 Vegetarian Pies 1,890
Feb Saturday Vegetarian Pies 118 118 £3.00
Mar Tuesday Chicken Pies 708 700 £3.50
Mar Tuesday Lamb Pies 290 284 £4.00 Count the number of times each product below sells out on a particular day:
Mar Tuesday Vegetarian Pies 86 86 £3.00
Mar Thursday Chicken Pies 896 860 £3.50 Tuesday Thursday Saturday
Mar Thursday Lamb Pies 357 357 £4.00 Chicken Pies 1 - 3
Mar Thursday Vegetarian Pies 132 125 £3.00 Lamb Pies 1 1 3
Mar Saturday Chicken Pies 900 801 £3.50 Vegetarian Pies 2 1 3
Mar Saturday Lamb Pies 374 370 £4.00
Mar Saturday Vegetarian Pies 140 140 £3.00
Apr Tuesday Chicken Pies 700 697 £3.50 You can use SUMPRODUCT to perform more bespoke calculations:
Apr Tuesday Lamb Pies 283 280 £4.00
Apr Tuesday Vegetarian Pies 100 97 £3.00 Weekday sales 13,994
Apr Thursday Chicken Pies 718 717 £3.50 Weekend sales 7,214
Apr Thursday Lamb Pies 295 292 £4.00 Total sales 21,208
Apr Thursday Vegetarian Pies 106 103 £3.00 Check -
Apr Saturday Chicken Pies 720 720 £3.50
Apr Saturday Lamb Pies 300 300 £4.00 In the example above, the + symbols acts like an OR function
Apr Saturday Vegetarian Pies 118 118 £3.00
May Tuesday Chicken Pies 892 891 £3.50
May Tuesday Lamb Pies 357 350 £4.00
May Tuesday Vegetarian Pies 128 120 £3.00
May Thursday Chicken Pies 894 890 £3.50
May Thursday Lamb Pies 359 351 £4.00
May Thursday Vegetarian Pies 131 128 £3.00
May Saturday Chicken Pies 720 719 £3.50
May Saturday Lamb Pies 300 289 £4.00
May Saturday Vegetarian Pies 112 110 £3.00
Jun Tuesday Chicken Pies 720 710 £3.50
Jun Tuesday Lamb Pies 283 281 £4.00
Jun Tuesday Vegetarian Pies 95 91 £3.00
Jun Thursday Chicken Pies 720 710 £3.50
Jun Thursday Lamb Pies 292 291 £4.00
Jun Thursday Vegetarian Pies 109 100 £3.00
Jun Saturday Chicken Pies 900 900 £3.50
Jun Saturday Lamb Pies 370 369 £4.00
Jun Saturday Vegetarian Pies 145 143 £3.00
Month Day of week Product Quantity Produced Quantity Sold Product Price
Jan Tuesday Chicken Pies 900 896 £3.50
Jan Tuesday Lamb Pies 400 365 £4.00 So, SUMPRODUCT can be used to perform relatively complex calculations based on multiple criteria:
Jan Tuesday Vegetarian Pies 150 136 £3.00 But there are multiple approaches you'll see modellers take. Look at the individual formulas in the three options below:
Jan Thursday Chicken Pies 708 600 £3.50
Jan Thursday Lamb Pies 280 279 £4.00 Revenue By Product: Option 1 Option 2 Option 3
Jan Thursday Vegetarian Pies 110 110 £3.00 Chicken Pies £47,698 £47,698 £47,698
Jan Saturday Chicken Pies 714 711 £3.50 Lamb Pies £22,400 £22,400 £22,400
Jan Saturday Lamb Pies 291 291 £4.00 Vegetarian Pies £5,940 £5,940 £5,940
Jan Saturday Vegetarian Pies 111 95 £3.00
Feb Tuesday Chicken Pies 685 685 £3.50
Feb Tuesday Lamb Pies 271 271 £4.00 Option 1: using "--" {=SUMPRODUCT(--($E$141:$E$194=$J146), $G$141:$G$194, $H$141:$H$194)}
Feb Tuesday Vegetarian Pies 100 100 £3.00 Option 2: using "N" {=SUMPRODUCT(N($E$141:$E$194=$J146), $G$141:$G$194, $H$141:$H$194)}
Feb Thursday Chicken Pies 714 701 £3.50 Option 3: using (( )) {=SUMPRODUCT(($E$141:$E$194=$J146) * $G$141:$G$194 * $H$141:$H$194)}
Feb Thursday Lamb Pies 291 280 £4.00
Feb Thursday Vegetarian Pies 100 60 £3.00 There's a lot to unpack here, but essentially you have three options available to you to ensure your SUMPRODUCT
Feb Saturday Chicken Pies 720 720 £3.50 returns the numerical values you're looking for.
Feb Saturday Lamb Pies 300 300 £4.00
Feb Saturday Vegetarian Pies 118 118 £3.00
Mar Tuesday Chicken Pies 708 700 £3.50 Whenever you have a functional argument (like we do above with the first array that's looking for a particular type of pie)
Mar Tuesday Lamb Pies 290 284 £4.00 we have to do some work to turn a TRUE / FALSE result into a 1 / 0 (so it will multiply out properly)
Mar Tuesday Vegetarian Pies 86 86 £3.00
Mar Thursday Chicken Pies 896 860 £3.50 "--" and "N" are two common approaches you'll see being used
Mar Thursday Lamb Pies 357 357 £4.00 An alternative with SUMPRODUCT is to use the brackets around the functional argument,
Mar Thursday Vegetarian Pies 132 125 £3.00 and to replace the comma with the * (multiplication) sign.
Mar Saturday Chicken Pies 900 801 £3.50 The * does the work to convert the TRUE / FALSE to a 1 / 0 for us
Mar Saturday Lamb Pies 374 370 £4.00
Mar Saturday Vegetarian Pies 140 140 £3.00
Apr Tuesday Chicken Pies 700 697 £3.50
Apr Tuesday Lamb Pies 283 280 £4.00
Apr Tuesday Vegetarian Pies 100 97 £3.00
Apr Thursday Chicken Pies 718 717 £3.50
Apr Thursday Lamb Pies 295 292 £4.00
Apr Thursday Vegetarian Pies 106 103 £3.00
Apr Saturday Chicken Pies 720 720 £3.50
Apr Saturday Lamb Pies 300 300 £4.00
Apr Saturday Vegetarian Pies 118 118 £3.00
May Tuesday Chicken Pies 892 891 £3.50
May Tuesday Lamb Pies 357 350 £4.00
May Tuesday Vegetarian Pies 128 120 £3.00
May Thursday Chicken Pies 894 890 £3.50
May Thursday Lamb Pies 359 351 £4.00
May Thursday Vegetarian Pies 131 128 £3.00
May Saturday Chicken Pies 720 719 £3.50
May Saturday Lamb Pies 300 289 £4.00
May Saturday Vegetarian Pies 112 110 £3.00
Jun Tuesday Chicken Pies 720 710 £3.50
Jun Tuesday Lamb Pies 283 281 £4.00
Jun Tuesday Vegetarian Pies 95 91 £3.00
Jun Thursday Chicken Pies 720 710 £3.50
Jun Thursday Lamb Pies 292 291 £4.00
Jun Thursday Vegetarian Pies 109 100 £3.00
Jun Saturday Chicken Pies 900 900 £3.50
Jun Saturday Lamb Pies 370 369 £4.00
Jun Saturday Vegetarian Pies 145 143 £3.00
SUMPRODUCT does also create little pockets of magic when it's used with other functions as well.
For example, let's say we wanted to count the number of characters across all of our text strings below.
You probably know already that we could add a column with a LEN formula and SUM the results in that new column.
But there's a shortcut…
Note: both of the examples above can also now be calculated with a simple SUM:
214 {=SUM(LEN(C205:E210))}
24 {=SUM(LEN(C205:C210) - LEN(SUBSTITUTE(C205:C210, "-", "")))}
Exercise
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Saturday -
Total - - - -
Exercise Solution
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 7
When she's not baking, Sarah is a big fan of squirrels. Below is a table of squirrel sightings that Sarah and her friend John have logged:
Forest of Dean
Green Wood
Hake Wood
Hales Wood
Pile Wood
Quantock Wood
Answer:
Sarah
John
Answer:
Grey
Red
Hake Wood
Red
Hake Wood
Sarah
Grey
Quantock Wood
John
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Solution 7
When she's not baking Sarah is a big fan of squirrels. Below is a table of squirrel sightings that Sarah and her friend John have logged:
Sarah 745
John 1,096
Answer: John
Grey 1,521
Red
Hake Wood 40
Red
Hake Wood
Sarah 40
Grey
Quantock Wood
John 180
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 8
1. Calculate the total revenue earned by week, without any helper columns, as set out below:
Week 1
Week 2
Week 3
Week 4
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Total Revenue
2. Calculate the total weekday and weekend revenue, without any helper columns, as set out below:
Weekday
Weekend
Total Revenue £0
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Exercise 8
1. Calculate the total revenue earned by week, without any helper columns, as set out below:
Week 1 £79,610 £79,610
Week 2 £60,315 £60,315
Week 3 £42,680 £42,680
Week 4 £45,834 £45,834
Week 5 £49,056 OR £49,056
Week 6 £47,872 £47,872
Week 7 £48,391 £48,391
Week 8 £77,530 £77,530
Week 9 £51,108 £51,108
Week 10 £65,504 £65,504
Total Revenue £567,899 £567,899
2. Calculate the total weekday and weekend revenue, without any helper columns, as set out below:
Weekday £396,234 £396,234
Weekend £171,666 OR £171,666
Total Revenue £567,899 £567,899
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The MOD Function
Key points
The MOD function returns the remainder of a division calculation
In its simplest form, it requires just two numeric values: the number and divisor
However, MOD can be used in more targeted ways to support advanced modelling challenges
In plain English:
When you divide the Number by the Divisor, the MOD function will return just the remainder from this calculation
The remainder is the numerical value that is left after accounting for the number of times the Divisor divides fully into the Number
OR
Quarterly Payment Flag 0 FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE
Converted to 1s and 0s 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 TRUE
And don't forget that all of this model timeline logic can be set up more dynamically now with functions like SEQUENCE at our disposal
No. of Period 27
Model Period Counter #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME?
Model Year - Month Counter #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME?
Quarter Counter #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME? #NAME?
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The QUOTIENT Function
Key points
The QUOTIENT function does the opposite of the MOD function
It returns the integer portion of a division calculation, discarding the remainder
In its simplest form, the QUOTIENT function requires just two numeric values
However, much like the MOD function, it can also be used to support and overcome more advanced modelling challenges
In plain English:
The QUOTIENT function returns the number of times the Denominator divides into the Numerator in full.
The remainder - the numerical value that is left after accounting for the number of times the Denominator divides into the Numerator - is discarded
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The INT Function
Syntax =INT(number)
Key points
The INT function returns a whole integer from a numerical value, discarding the remainder (much like QUOTIENT), but performs a round down BEFORE the remainder is discarded
Be aware that negative numbers will become more negative if that are used within the INT function
The syntax could not be simpler: you have just one element to add - the number you wish to return the integer for
Modellers seeking to avoid the round down step can use the TRUNC function instead
Or they could just use some of the functions on the next worksheet instead! But let's stick with INT for now…
Number 3.756 3.000 =INT(D17) The INT function discards the remainder
(3.756) (4.000) =INT(D18) With negative numbers, the initial round down step becomes clearer
(3.756) (3.000) =TRUNC(D19) The negative round down issue can be overcome by using the TRUNC function instead of INT
In plain English:
The INT function returns a whole number when you reference a decimal number
The function will round down, which doesn't cause any noticeable issues for positive numbers, but does throw up potentially confusing results for negative numbers
Let's use the INT function to return the age of a team of people
The YEARFRAC function used above simply converts the time difference between two dates into a decimal number
The TODAY function generates today's date (which is then used as one half of the calculation for the YEARFRAC calculation
INT leaves us with just the whole number of years for each individual's age
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The ROUND, ROUNDUP & ROUNDDOWN Functions
Key points
We won't dwell on these functions too long as they couldn't really be much clearer
ROUND, ROUNDDOWN, and ROUNDUP do exactly what you would expect them to do
Using these functions, instead of INT (and potentially TRUNC), offers a simpler solution to the negative values issue highlighted on the last worksheet
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The OFFSET function
Key points
The OFFSET function is one of the most unique, potentially powerful, and potentially dangerous functions in Excel
As a volatile function (one that recalculates with each workbook change), and one that can be extremely difficult to review and follow, it must be very carefully considered before it is used
We consider it an advanced function for these reasons, but one that modellers should be aware of and lean on when it can add real value
When using OFFSET we first identify a starting cell reference and then choose row and / or column numbers to offset (move) from that reference point
The formula in cell D21 returns the value in cell G21, as the OFFSET function has shifted the reference 3 rows down from D18 (negative numbers would shift the reference up), and 3 columns right (negative numbers shift the reference left)
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Pork pie Bath 10,000
Pork pie Bristol 20,000
Pork pie Cardiff 30,000
In plain English:
Starting from cell D29, offset by 3 rows and 0 columns
Rows 3
Cols 1 Swindon =OFFSET(C29,D56,D57)
Height 1
Width 1
We can combine OFFSET with the SUM function to create a dynamic range
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Row offset 3
Column offset 2
Height 3
Width 1
Can you work out which cells are being summed up?
It's pretty difficult isn't it.
In plain English:
Starting from cell C66 offset by 3 rows and 2 columns for a range that is three cells high and 1 cell wide
Application
The examples above give you a generic view of the way OFFSET works, but not a great example of why you would ever choose to use it
Let's try to bring OFFSET to life a bit with an example of some very basic tax workings within a Timeline
Column counter 1 2 3 4 5 6 7 8 9 10 11 12
Tax period end value - - 100,000 - - - - - - - - -
Tax payment - - - 100,000 - - - - - - - -
In this example we use OFFSET to refer one column backwards (negative values within OFFSET move left, positive values move right)
We can take this tax example further to showcase the way OFFSET can be used to refer to a dynamic range
Column counter 1 2 3 4 5 6 7 8 9 10 11 12
Periodic tax values 30,000 40,000 30,000 24,000 40,000 35,000 37,000 28,000 16,000 23,000 29,000 32,000
Tax period end flag - - 1 - - 1 - - 1 - - 1
Tax period end value Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502
Tax payment Tax period end value Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502 Err:502
Can you see the error that has been created above due to the movement in the OFFSET function?
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
The INDIRECT function
Key points
The INDIRECT function returns the reference specified by a text string.
The INDIRECT function is another volatile and potentially difficult function to interpret, which means it should be used carefully.
We consider it an advanced function for these reasons, but one that modellers should be aware of.
Product Price
Chicken Pie £ 2.75
Lamb Pie £ 3.00
Vegetarian Pie £ 3.25
Pork pie £ 3.15
In plain English:
The INDIRECT function returns the value in the cell with the cell reference contained in D24 (D20)
We can also use named ranges in an INDIRECT function in conjunction with other functions.
In the example below the cells with sales figures from Jan to Mar for each bakery have been given a named range matching the description of the bakery.
Review the Name Manager on the Formulas ribbon if you would like to check the named ranges
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Bakery_C 2,000 1,000 1,600 named range: D39:F39 "Bakery_C"
Bakery_D 600 900 600 named range: D40:F40 "Bakery_D"
Bakery_E 1,100 1,900 2,000 named range: D41:F41 "Bakery_E"
Now we can use INDIRECT and the bakery dropdown list below to return the SUM of all sales for the chosen bakery
We can also use INDIRECT to return a value from different worksheets. This can bring some sense of consistency and reduce the number of unique formulas in some instances:
Below we use INDIRECT in the grey cells to return the Syntax from each listed worksheet within this workbook, with one unique formula.
Below we have a set of lists that are set up as Excel Tables (do not worry about the details behind Excel Tables if you are unfamiliar with them - we will cover these later on in the course).
One table lists the name of each Bakery (column C), and the other tables list the names of the staff members that work at each bakery.
Within each table, the range of bakery staff names have also been set up as a named range.
Staff Names
Bakeries Bakery_1 Bakery_2 Bakery_3
Bakery_1 Sally H Sharon R Paula E
Bakery_2 Paul B Ross L Dave B
Bakery_3 John E Tom F
Sue P
Now we can use these named ranges and the INDIRECT function to create a dependent drop down list:
1) Choose the Bakery from the first drop down list: Bakery_2
Clarity Consultancy Services Ltd [email protected]
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
2) Choose from the staff name list in this dynamic second drop down list: Ross L This cell has a drop down list that is dynamic.
INDIRECT has been added to Data Validation to make it so.
Try changing the bakery selected in step one and see what happens to the drop down list in step two
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY
Using Flags in modelling
Key points
A flag is a value in a cell that indicates a simple, binary outcome
They are typically represented as TRUE or FALSE, 1 or 0, "On" or "Off", or "Yes" or "No" (often depending on mod
Flags can be used as visual aids using a "Yes" or "No" for example, often combined with conditional formatting
The most powerful use of flags is often a simple 1 or 0 when being applied within a formula. This is because multip
Mastering the use of flags in your modelling is one of the most important steps you can make in your modelling ca
There are many alternative approaches you'll see modellers taking to reach the same outcom
The key point is that you understand the power of being able to create 1 and 0 flags, and you
It might seem a little strange but you actually do not need the step to switch the TRUE to a 1 a
In modelling, because we should always be thinking of the end user, it is generally accepted th
Sarah would like to sum up the total revenue for market days where is was sunny
Market Day 1 Tuesday
Market Day 2 Thursday
Market Day 3 Saturday
In financial modelling flags are typically used in a single row to indicate whether something is ac
We would like to identify the first period in the model with a flag of one
Firstly let's create the formula in a tabular (vertical) form as we have above
Date Flag
1/31/2022 0
2/28/2022 0
3/31/2022 0
4/30/2022 0
5/31/2022 0
6/30/2022 1
7/31/2022 0
8/31/2022 0
9/30/2022 0
10/31/2022 0
11/30/2022 0
12/31/2022 0
Now let's flip the data over onto a horizonal layout as we would see in a financial model
We can also create a flag to determine whether the period is in scope of the forecast or not
We can then use this flag to control whether a value is included or not
Pre-forecast vs forecast 0 - -
Monthly cost 50 50
Result - -
r "Yes" or "No" (often depending on modeller preference)
combined with conditional formatting
d within a formula. This is because multiplying by a 1 returns a value, whilst multiplying by 0 always returns 0
teps you can make in your modelling career
Using the IF function we can convert the We can then add a simple formula to
TRUE to a 1 and the FALSE to 0 flag and add them up
Day Value Is Monday Day
Monday 450 1 Monday
Tuesday 500 0 Tuesday
Wednesday 600 0 Wednesday
Thursday 500 0 Thursday
Friday 900 0 Friday
Saturday 1,200 0 Saturday
Sunday 1,300 0 Sunday
Monday 504 1 Monday
Tuesday 560 0 Tuesday
Wednesday 672 0 Wednesday
Thursday 560 0 Thursday
Friday 1,008 0 Friday
Saturday 1,344 0 Saturday
Sunday 1,456 0 Sunday
Monday 432 1 Monday
Tuesday 480 0 Tuesday
Wednesday 576 0 Wednesday
Thursday 480 0 Thursday
Friday 864 0 Friday
Saturday 1,152 0 Saturday
Sunday 1,248 0 Sunday
e step to switch the TRUE to a 1 and the FALSE to a zero. Excel already sees TRUE as 1 and FALSE as 0:
nd user, it is generally accepted that it is better to use 1s and 0s instead of TRUE and FALSE simply becaus
example
indicate whether something is active or inactive (TRUE or FALSE, on or off) across the time period
have above
see in a financial model
ed or not
- - - 1 1
100 100 80 80 90
- - - 80 90
ways returns 0
UE and FALSE simply because it's easier to understand for most users.
h the "Is Market Day" and "Is Sunny" are 1s the value is brought through into column H
1 1 1 1 1
90 100 120 150 120
90 100 120 150 120
Some Specific Battle Ideas To Round This Off!
You have a lot of structural flexibility available to you when it comes to formulas like SUMIFS, COUNTIFS, even SUM to be honest, and the ranges you set up within the function's parameters.
Let's take a really basic game to walk through this in more detail:
A B C D E F G H
1 ♥ ♦ ♠ ♣ ♥ ♦ ♥ ♠
2 ♣ ♣ ♦ ♣ ♦ ♠ ♠ ♣
3 ♠ ♠ ♠ ♠ ♥ ♣ ♦ ♦
4 ♦ ♥ ♦ ♥ ♦ ♣ ♠ ♣
5 ♣ ♠ ♣ ♣ ♠ ♠ ♥ ♦
6 ♦ ♦ ♠ ♥ ♠ ♣ ♥ ♠
7 ♥ ♠ ♠ ♦ ♦ ♣ ♠ ♦
8 ♦ ♥ ♥ ♣ ♣ ♦ ♥ ♣
Round 1:
What is the count of each suit in the board position referenced below plus those cells directly surrounding them (including diagonals):
Board Ref ♣ ♥ ♠ ♦
B4 2 1 4 2 {=COUNTIFS($C$27:$E$29, D$43:$G$43)}
E7 4 1 1 3 {=COUNTIFS($F$30:$H$32, D$43:$G$43)}
H1 1 1 2 0 {=COUNTIFS($I$22:$K$26, D$43:$G$43)}
Take a moment to look at the ranges we're setting up in the formulas within the grey cells above.
We're using ranges that surround a cell reference, to count the number of times each suit appears around it.
Note: we can count symbols / emojis just like we would a letter or number.
What if round 2 in the battle asked us to convert these cell positions (let's say the player "lands" on B4, E7 and H1 during the game) into points, based on the suit & points key presented above
You'll have to add the points from the suit of the cell landed on plus the points from the suits of all surrounding cells (the same logic as in round 1)
A B C D E F G H
Note that is the formulas in the second grid above, we're using one cell reference that links back to the first board grid, with no absolute referencing, and a fixed lookup reference to the suits points key.
Or we could have made our lives much easier and avoided the need for the second grid altogether:
♣ ♥ ♠ ♦ Total
B4 #NAME? #NAME? #NAME? #NAME? #NAME?
E7 #NAME? #NAME? #NAME? #NAME? #NAME?
H1 #NAME? #NAME? #NAME? #NAME? #NAME?
What if we wanted to build out a solution, maybe to start answering some of the more complex battle questions, that allowed us to dynamically change the player's board position and calculate the score?
Assume the scoring remains the same: it's the sum of the suit the player lands on plus the points from all surrounding boards spaces based on the first board grid we showed above.
There are a few ways we could go about this (no doubt experienced players will know of more as well!)
Let's start with a neat trick to produce a grid of the board position references
That's pretty useful, but we could also cut this step and convert this to a list, with the suits listed alongside each board position reference:
Registered in the UK (6619745). Registered Office: Suite 6 Bourne Gate, Bourne Valley Rd, Poole, BH12 1DY