Intro to Functions and Syntax
- 06:35
Understand the application of pre build formulas in Excel
Transcript
Functions are an extension of a formula. If we think a formula calculates a cell's value such as A1 plus A2, well that would give me the sum of the contents. So maybe A1 has 10 in it and A2 has a two in it. That would give me 12. That's a formula. But functions are automated formulas built into Excel to try and make things a bit quicker. For example, we could have equals sum a one, colon a two. If it said a one colon a five, it would sum all of the cells in between a one and a five. So 1, 2, 3, 4, and five. This particular sum function on screen isn't going to save us much time compared to the A1 plus A2 above. But some functions do save us a lot of time and we can think of them as being similar to buttons on a calculator that do a lot of work behind the scenes to save us time. For instance, if I wanted to find the logarithm of a number, I could easily press the log button on my calculator. Let's use the sum function as a good introduction to functions in general, if I type in equals sum, this is what appears in Excel. You firstly have the function name. Then in brackets you get the argument i,e. what you need to include. In this case, it's number one, and then you've got the option of number two, and that's why it's in square brackets. This whole thing is called the syntax. It's shown on screen and this is Excel trying to tee you up, trying to tell you what needs to be included, but Excel can help us even more. What you can do is you can insert a function by clicking on the insert function button. We then get the insert function dialogue box on the right hand side here, which walks us through the function. Let's look at an example in Excel.
Here I have two columns of costs. One is in pounds, the other in US dollars, and I want to sum them up. Firstly, I'm going to use the sum function. So I type in equals sum open bracket, and now the syntax has appeared just underneath the formula bar. This is Excel helping me out. It's telling me I need to include number one and then maybe number two, et cetera. I'm gonna use my mouse to, first Of all, click on B2. Then I'm going to press comma, click on B3 comma B4, close bracket, and press enter.
Be careful because in some jurisdictions you'll need to use a semicolon rather than a comma, so just try and find out which one your computer is using.
An alternative way I could have done this is type equals sum, open square brackets, then clicked into B2 and dragged down to B4 before closing brackets and pressing enter.
You can see the formula now has a semicolon between B2 and B4.
Alternatively, I could have typed equals some open square brackets and use the arrow keys on my keyboard to go up to B2, hold down shift and the down arrow until I get to B4 close bracket and enter.
So that's writing the function ourselves. Let's go into the next column, and this time let's use the insert function button here up at the top. When I click on that, the insert function dialogue box now appears and up at the top it's telling me to search for a function. So if I delete the text out of there, I type in some go and I can see in the box below we have all the functions that have some in it, and I want the first one.
Alternatively, I could have selected a category. If I click on the dropdown, I know some falls under math and tri, so that's another way of getting to the sum function.
I've selected some. I'm going to press okay, and a second dialogue box pops up and in number one, Excel is trying to help me out. It's guessing which cells to add up. It's correctly guessed, but be careful. It won't always get this right, so you do need to check it yourself. Underneath this, it gives me some extra help. It tells me that the sum function adds all the numbers in a range of cells. It tells me that these cells add up to 312. It then tells me that the number one, number two are one to 255 numbers. So I could include 255 separate numbers in here. Logical values and text are ignored.
I'm going to press, okay, and that gives me the sum of the three cells above, which is 312. So in summary, I could type my function in so equals some open brackets or alternatively, I can go up to the formula bar and click on the insert function button.