Syntax:= VAR.S (number1, [number2], …)
The VAR.S function syntax has the following arguments:
Number2, … Optional. Number arguments 2 to 254 corresponding to a sample of a population.
Example: Let’s look at some Excel VAR.S function examples and explore how to use the VAR.S function as a worksheet function in Microsoft Excel:
Suppose we are given data about the height of children from three cities (in cm), as shown below:
The variance of the heights of the sample group is calculated in cell B16 of the spreadsheet. The formula for this, (shown in the formula bar), is:
Syntax: =VAR.S(B3:B14,D3:D14,F3:F14)
Result: 40.36
The calculated variance of the individual heights of the sample group is 40.36 cm.
The example above shows the arguments to the Var.S function being input in the form of 3 cell ranges. However, you can also input figures directly, as individual numbers or number arrays.
For example, if you wanted to include two further heights, of 163cm and 155cm into the sample, you could add these directly into the above function as follows:
Either as individual numbers:
Syntax: =VAR.S(B3:B14,D3:D14,F3:F14,163,155)
Result: 39.06
or, as an array of numbers:
Syntax: =VAR.S(B3:B14,D3:D14,F3:F14,{163,155})
Result: 39.06
Note:
]]>
Let’s count the ways: Excel PivotTables are easy to build and maintain; they perform large and complex calculations amazingly fast; you can quickly and easily update them to account for new data; PivotTables are dynamic, so components can be easily moved, filtered, and added to; and, finally, PivotTables can use most of the formatting options that you can apply to regular Excel ranges and cells.
Oh, wait, there’s one more: PivotTables are fully customizable, so you can build each report the way you want. Here are ten techniques that will turn you into a PivotTable pro.
By default, when you click inside the PivotTable, Excel displays the PivotTable Fields task pane and then hides the PivotTable Fields task pane again when you click outside the PivotTable report.
Nothing wrong with that on the face of it. However, if you want to work with the commands in the Ribbon’s PivotTable Tools contextual tab, you need to have at least one cell in the PivotTable report selected. But selecting any PivotTable cell means that you also have the PivotTable Fields task pane taking up precious screen real estate.
Fortunately, Excel also enables you to turn the PivotTable Fields task pane off and on by hand, which gives you more room to display your PivotTable report. You can then turn the PivotTable Fields task pane back on when you need to add, move, or delete fields.
To toggle the PivotTable Fields task pane off and on, follow these steps (all two of them!):
By default, the PivotTable Fields task pane is divided into two sections: the Fields section lists the data source’s available fields and appears at the top of the pane, and the Areas section contains the PivotTable areas — Filters, Columns, Rows, and Values — and appears at the bottom of the pane. You can customize this layout to suit the way you work. Here are the possibilities:
Here are the steps to follow to change the PivotTable Fields task pane layout:
The main advantage to using PivotTables is that they give you an easy method for summarizing large quantities of data into a succinct report for data analysis. In short, PivotTables show you the forest instead of the trees. However, sometimes you need to see some of those trees. For example, if you’re studying the results of a marketing campaign, your PivotTable may show you the total number of earbuds sold as a result of a 1 Free With 10 promotion. However, what if you want to see the details underlying that number? If your source data contains hundreds or thousands of records, you need to filter the data in some way to see just the records you want.
Fortunately, Excel gives you an easier way to see records you want by enabling you to directly view the details that underlie a specific data value. This is called drilling down to the details. When you drill down into a specific data value in a PivotTable, Excel returns to the source data, extracts the records that comprise the data value, and then displays the records in a new worksheet. For a PivotTable based on a range or table, this extraction takes but a second or two, depending on how many records the source data contains.
To drill down into the details underlying a PivotTable data point, use either of the following methods:
Excel displays the underlying data in a new worksheet. For example, this image shows the details behind the 792 earbuds sold with the 1 Free with 10 promotion shown in the image above.
When you attempt to drill down to a data value’s underlying details, Excel may display the error message Cannot change this part of a PivotTable report
. This error means that the feature that normally enables you to drill down has been turned off. To turn this feature back on, click any cell inside the PivotTable and then click Analyze → PivotTable → Options to display the PivotTable Options dialog box. Click the Data tab, select the Enable Show Details check box, and then click OK.
The opposite situation occurs when you distribute the workbook containing the PivotTable and you don’t want other users drilling down and cluttering the workbook with detail worksheets. In this case, click Analyze → PivotTable → Options, click the Data tab, deselect Enable Show Details, and then click OK.
Sometimes you may want to see all of a PivotTable’s underlying source data. If the source data is a range or table in another worksheet, you can see the underlying data by displaying that worksheet. If the source data is not so readily available, however, Excel gives you a quick way to view all the underlying data. Right-click the PivotTable’s Grand Total cell (that is, the cell in the bottom-right corner of the PivotTable) and then click Show Details. (You can also double-click that cell.) Excel displays all of the PivotTable’s underlying data in a new worksheet.
One of the nice things about a PivotTable is that it resides on a regular Excel worksheet, which means that you can apply formatting options such as alignments and fonts to portions of the PivotTable. This works well, particularly if you have custom formatting requirements.
For example, you may have in-house style guidelines that you need to follow. Unfortunately, applying formatting can be time consuming, particularly if you’re applying a number of different formatting options. And the total formatting time can become onerous if you need to apply different formatting options to different parts of the PivotTable. You can greatly reduce the time you spend formatting your PivotTables if you apply a style instead.
A style is a collection of formatting options — fonts, borders, and background colors — that Excel defines for different areas of a PivotTable. For example, a style might use bold, white text on a black background for labels and grand totals, and white text on a dark blue background for items and data. Defining all these formats manually might take half an hour to an hour. But with the style feature, you choose the one you want to use for the PivotTable as a whole, and Excel applies the individual formatting options automatically.
Excel defines more than 80 styles, divided into three categories: Light, Medium, and Dark. The Light category includes Pivot Style Light 16, the default formatting applied to PivotTable reports you create; and None, which removes all formatting from the PivotTable. You can also create your own style formats.
Here are the steps to follow to apply a style to an Excel PivotTable:
You may find that none of the predefined PivotTable styles gives you the exact look that you want. In that case, you can define that look yourself by creating a custom PivotTable style from scratch.
Excel offers you tremendous flexibility when you create custom PivotTable styles. You can format 25 separate PivotTable elements. These elements include the entire table, the page field labels and values, the first column, the header row, the Grand Total row, and the Grand Total column. You can also define stripes, which are separate formats applied to alternating rows or columns. For example, the First Row Stripe applies formatting to rows 1, 3, 5, and so on; the Second Row Stripe applies formatting to rows 2, 4, 6, and so on. Stripes can make a long or wide report easier to read.
Having control over so many elements enables you to create a custom style to suit your needs. For example, you might need your PivotTable to match your corporate colors. Similarly, if the PivotTable will appear as part of a larger report, you might need the PivotTable formatting to match the theme used in the larger report.
The only downside to creating a custom PivotTable style is that you must do so from scratch because Excel doesn’t enable you to customize an existing style. Boo, Excel! So if you need to define formatting for all 25 PivotTable elements, creating a custom style can be time consuming.
If you’re still up for it, however, here are the steps to plow through to create your very own Excel PivotTable style:
Weirdly, after you close the New PivotTable Style dialog box, Excel doesn’t apply the new style to the current PivotTable. Dumb! To apply the style yourself, select any cell within the PivotTable, click Design, click the More button in the PivotTable Styles group to open the style gallery, and then click your style in the Custom section that now appears at the top of the gallery.
If you need to make changes to your custom style, open the style gallery, right-click your custom style, and then click Modify. Use the Modify PivotTable style dialog box to make your changes, and then click OK.
If you find that you need to create another custom style that’s similar to an existing custom style, don’t bother creating the new style from scratch. Instead, open the style gallery, right-click the existing custom style, and then click Duplicate. In the Modify PivotTable style dialog box, adjust the style name and formatting, and then click OK.
If you no longer need a custom style, you should delete it to reduce clutter in the style gallery. Click the Design tab, open the PivotTable Styles gallery, right-click the custom style you no longer need, and then click Delete. When Excel asks you to confirm, click OK.
Excel has a nasty habit of sometimes not preserving your custom formatting when you refresh or rebuild the PivotTable. For example, if you applied a bold font to some labels, those labels might revert to regular text after a refresh. Excel has a feature called Preserve Formatting that enables you to preserve such formatting during a refresh; you can retain your custom formatting by activating it.
The Preserve Formatting feature is always activated in default PivotTables. However, another user could have deactivated this feature. For example, you may be working with a PivotTable created by another person and he or she may have deactivated the Preserve Formatting feature.
Note, however, that when you refresh or rebuild a PivotTable, Excel reapplies the report’s current style formatting. If you haven’t specified a style, Excel reapplies the default PivotTable style (named Pivot Style Light 16); if you have specified a style, Excel reapplies that style.
Here are the steps to follow to configure an Excel PivotTable to preserve formatting:
When you create the first PivotTable in a workbook, Excel gives it the uninspiring name PivotTable1. Subsequent PivotTables are named sequentially (and just as uninspiringly): PivotTable2, PivotTable3, and so on. However, Excel also repeats these names when you build new PivotTables based on different data sources. If your workbook contains a number of PivotTables, you can make them easier to distinguish by giving each one a unique and descriptive name. Here’s how:
A default PivotTable that has at least one row field contains an extra row at the bottom of the table. This row is labeled Grand Total and includes the total of the values associated with the row field items. However, the value in the Grand Total row may not actually be a sum. For example, if the summary calculation is Average, the Grand Total row includes the average of the values associated with the row field items.
Similarly, a PivotTable that has at least one column field contains an extra column at the far right of the table. This column is also labeled “Grand Total” and includes the total of the values associated with the column field items. If the PivotTable contains both a row and a column field, the Grand Total row also has the sums for each column item, and the Grand Total column also has the sums for each row item.
Besides taking up space in the PivotTable, these grand totals are often not necessary for data analysis. For example, suppose you want to examine quarterly sales for your salespeople to see which amounts are over a certain value for bonus purposes. Because your only concern is the individual summary values for each employee, the grand totals are useless. In such a case, you can tell Excel not to display the grand totals by following these steps:
PivotTables often result in large workbooks because Excel must keep track of a great deal of extra information to keep the PivotTable performance acceptable. For example, to ensure that the recalculation involved in pivoting happens quickly and efficiently, Excel maintains a copy of the source data in a special memory area called the pivot cache.
If you build a PivotTable from data that resides in a different workbook or in an external data source, Excel stores the source data in the pivot cache. This greatly reduces the time Excel takes to refresh and recalculate the PivotTable. The downside is that it can increase both the size of the workbook and the amount of time Excel takes to save the workbook. If your workbook has become too large or it takes too long to save, follow these steps to tell Excel not to save the source data in the pivot cache:
You might need to use a PivotTable value in a worksheet formula. You normally reference a cell in a formula by using the cell’s address. However, this won’t work with PivotTables because the addresses of the report values change as you pivot, filter, group, and refresh the PivotTable.
To ensure accurate PivotTable references, use Excel’s GETPIVOTDATA function. This function uses the data field, PivotTable location, and one or more (row or column) field/item pairs that specify the exact value you want to use. This way, no matter what the PivotTable layout is, as long as the value remains visible in the report, your formula reference remains accurate.
Here’s the syntax of the GETPIVOTDATA function:
GETPIVOTDATA(data_field, pivot_table, [, field1, item1][, …]
The two required fields are data_field
, which is the name of the field you’re using in the PivotTable’s Values area, and pivot_table
, which specifies the cell address of the upper-left corner of the PivotTable. The rest of the arguments come in pairs: a field name and an item in that field.
For example, here’s a GETPIVOTDATA formula that returns the PivotTable value where the Product
field item is Earbuds
and the Promotion
field item is 1 Free with 10
:
=GETPIVOTDATA("Quantity", $A$3, "Product", "Earbuds", "Promotion", "1 Free with 10")
GETPIVOTDATA is a bit complicated, but don’t fret. You’ll almost never have to peck out this function and all its arguments by hand. Instead, Excel conveniently handles everything for you when you click the PivotTable value you want to use in your formula. Phew!
]]>This table contains well over 100 records, each of which is an order from a sales promotion. That’s not a ton of data in the larger scheme of things, but trying to make sense of even this relatively small data set just by eyeballing the table’s contents is futile. For example, how many earbuds were sold via social media advertising? Who knows? Ah, but now look at the image below, which shows an Excel PivotTable built from the order data. This report tabulates the number of units sold for each product based on each promotion. From here, you can quickly see that 322 earbuds were sold via social media advertising. That is what PivotTables do.
PivotTables help you analyze large amounts of data by performing three operations: grouping the data into categories; summarizing the data using calculations; and filtering the data to show just the records you want to work with:
You can also create your own grouping after you build your PivotTable. For example, if your data has a Country field, you can build the PivotTable to group all the records that have the same Country value. When you have done that, you can further group the unique Country values into continents: North America, South America, Europe, and so on.
Even more powerful, a PivotTable can display summaries for one grouping broken down by another. For example, suppose your sales data also has a Product field. You can set up a PivotTable to show the total Sales for each Product, broken down by Region.
You can get up to speed with PivotTables very quickly after you learn a few key concepts. You need to understand the features that make up a typical PivotTable, particularly the four areas — row, column, data, and filter — to which you add fields from your data. Check out the following PivotTable features:
Recently, I posted an article about the magic of pivot tables . If you’ve already mastered creating pivot tables, here are a few advanced features… once you start using these, you’ll wonder how you ever survived without them!
1. Sort alphabetically or numerically.
Suppose your pivot table is calculating the average click through rate of your email sends and you want to rank the results from lowest to highest click through rate.
Suppose you have a pivot table with a long list of dates that you want to group by month. You can do this in a snap with the Grouping feature. In this screenshot, I right-clicked on a random “Email date” and selected “Group” from the popup menu.
You can actually use the Grouping feature for any label type, not just dates. Just highlight the rows you want to put into one group and select the “Group” option. Once your group has been created, you can then type over the default group name to label the group however you’d like.
Don’t like the order of your rows? This happens to me a lot. A simple and quick fix is to simply drag and drop the row.
To do this, select the row you want to move and hover over the edge until you see the crosshairs with arrows. Then simply drag and drop it higher or lower in the table.
In the example at right, I’m dragging and droping the “Event Invitation” row up above “Breaking News”.
4. Filter values, columns, or rows.
For example, if I wanted to hide all of the rows with a click through rate under 30%, I would select “Value Filters” from the popup menu.
]]>The short description of SUBTOTAL in Excel is quite vage: Returns a subtotal in a list or database
In order to be more specific: The SUBTOTAL formula can perform a mathematical calculation to one or more cell ranges. Instead of only being able to perform one fixed operation, you can choose the calculation type (e.g. sum, count, average) as an input variable. Furthermore, the SUBTOTAL formula has some more great advantages towards the distinct formulas.
The SUBTOTAL formula has (at least) two parts. The function type as well as the cell reference. Why “at least”? Because you can add up to 254 cell references.
The arguments of the SUBTOTAL formula are shown above:
There are 11 different operations you can use with the SUBTOTAL function. They are numbered by values from 1 to 11. You can use each of those functions types in two different ways:
All available functions are summarized in the table below. But don’t worry, you don’t have to remember all of them. When you start typing =SUBTOTAL( into an Excel cell, Excel will provide a list of available functions with their numbers.
Now we are getting to the interesting part. It will also explain why should you use SUBTOTAL. So far everything we know is also covered by easier formulas. For example =SUM() also adds up values.
But: SUBTOTAL doesn’t ignore hidden columns! Only rows.
Let’s jump right in with an example after so much theoretical knowledge.
You got some data in column B and C. Now you want to use the SUBTOTAL formula for summarizing it in the table on the right side. You want to get the following functions:
The SUBTOTAL formula for the average is quite simple: =SUBTOTAL(1,”CELL RANGE”) . Instead of just typing “1” as the first argument, you can also link to the cell defining the operation. In this case the function number if given in column F so you just link to cell F3.
The second argument is the cell range. In this example it’s the range C3 to C15. In order to fix the cell range you can add the $ signs. When you copy the formula into the cells G4 and G5, this range will persist. Combining these two arguments, the complete formula is =SUBTOTAL(F3,$C$3:$C$15) .
Excel can help you to insert the SUBTOTAL function. All you need: Your data must be in a database format. That means the format has to be similar to when you insert a PivotTable. Please refer to this article for more information about how to achieve such data structure.
Let’s say you got the data as shown in the image on the right side. It contains a short description in column B, a data type and a value. You want to organize and summarize your table by the data type in column C.
The first step: Sort the data. If you want to summarize the table by the type in column C, you have to sort it by column C. The reason for that: Excel adds a new column with a SUBTOTAL formula under each change of type.
Once your data is sorted, select the complete table and click “Subtotal” within the Outline groups. It’s located on the right side of the Data ribbon.
Now you see a new windows which looks like the one on the right. It basically has 5 sections:
Click “OK”. The result of the SUBTOTAL structure looks like on the right side. Excel not only inserts the SUBTOTAL rows. It also provides the matching outline structure.
The formula in cell D9 is: =SUBTOTAL(9,D3:D8) and the formula in cell D19 (the Grand Totals): =SUBTOTAL(9,D3:D17) .
If you want to summarize your table by one more criteria, repeat these steps. But make sure you don’t set the tickmarks at “Replace the current subtotals”.
In many cases, your Excel table has some “level” structure: You got a lot of rows containing data. In between you got sums and those sums in return add up to a total. That could be the case for a balance sheet or P&L statements (see the picture).
You got two options for getting such table:
If you take a look at the formulas of Method 1 you will see, that it takes some care to apply them. You really have to be cautious to get link the sums and “+”-operations to the correct cells. It might be fine in this example because you only have 10 rows. But in reality such tables are much longer.
In contrast the Grand Total (here: Profit) of Method 2 can comfortably stretch over the complete cell range. Furthermore, you can be sure that all input values are regarded once.
There is another common usage for SUBTOTAL: Get quick results from large sets of data. Typically the formula is above your actual data. Depending on what you select in your database below, the SUBTOTAL formula always shows the result of the current selection.
For such application, you Excel provides the function types 101 to 111 of the SUBTOTAL formula. Please take a look at the picture on the right side. The upper cells (range B2 to D5) contain the summary with the SUBTOTAL formulas. The lower cell range (B7 to D20) contain the data with filters.
The filter in column C (cell C7) is set to “Type 3”. Only two rows are shown. The summary block above has the result of the visible values in column D. You can easily use the SUBTOTAL formula. It has only two parts:
The complete formula looks like this: =SUBTOTAL(C3,$D$8:D$D$20)
Please note: This only works on hidden rows. If you hide or group columns, SUBTOTAL will regard also hidden cell. Please take a look at the example on the right side. If only visible cells are regarded, this formula would return 25. But SUBTOTAL does not disregard hidden columns. Therefore, the result is not 25 but also includes the values in the hidden columns D to N.
SUBTOTAL is very useful in the following cases:
Excel even helps you applying SUBTOTALs to your data. Unfortunately, SUBTOTAL is not very known. The reason: All of it’s functions can somehow (less comfortably) achieved by other formulas. But once integrated in your daily worklife, it can be a great help.
]]>
Syntax:= Z.TEST(array,x,[sigma])
The Z.TEST function syntax has the following arguments:
Example: Let’s look at some Excel Z.TEST function examples and explore how to use the Z.TEST function as a worksheet function in Microsoft Excel:
Example 1:
To calculate the one-tailed probability value of a Z Test for the above data, let’s assume the hypothesized population mean is 5, now we will use the Z TEST formula as shown below:
Syntax: =Z.TEST(A2:A13,5)
Result: 0.000123409
We can also calculate the two-tailed probability of a Z TEST here by using the above result.
The formula is given below for calculating the two-tailed P-value of a Z TEST for given hypothesized population means which is 5.
Syntax: =2*B16
Result: 0.000246818
Two Sample Z Test:
While using the Z Test, we test a null hypothesis which states that the mean of the two population is equal.
i.e.
H_{0}: µ_{1 – }µ _{2} = 0
H_{1}: µ_{1 – }µ _{2} ≠ 0
Where H1 is called an alternative hypothesis, the mean of two populations is not equal.
Example 2:
Let’s take the example of student’s marks of two different subjects.
Step 1: The first thing we need to do is to calculate the variables for these two values by using VAR.P function.
Syntax: =VAR.P(B2:B17)
Result: 126.5273438
Syntax: =VAR.P(C2:C17)
Result: 148.1835938
Step 2: Now go to the Data tab and click on Data Analysis.
Step 3: For Variable 1 Range select “Student 1” scores and for Variable 2 Range select “Student 2” scores.
Step 4: Variable 1 Variance select Student 1 variance score and Variable 1 Variance select Student 2 variance score.
Step 5: Select the Output Range as a cell and press Ok.
we got the result.
If Z < – Z Critical Two Tailor Z > Z Critical Two Tail, then we can reject the null hypothesis.
So from the ZTEST result below are results.
Since it is meeting our criteria we can reject the null hypothesis. So the means of two students differ significantly.
Note:
]]>
Syntax:= WEIBULL.DIST(x,alpha,beta,cumulative)
The WEIBULL.DIST function syntax has the following arguments:
Cumulative Required. Determines the form of the function.
Example: Let’s look at some Excel WEIBULL.DIST function examples and explore how to use the WEIBULL.DIST function as a worksheet function in Microsoft Excel:
Suppose we are given the following data:
The formula to be used for the Weibull Cumulative Distribution Function is:
Syntax: =WEIBULL.DIST(B1,B2,B3,TRUE)
Result: 0.035020028
The formula to be used for the Weibull Probability Density Function is:
Syntax: =WEIBULL.DIST(B1,B2,B3,FALSE)
Result: 0.011768264
Note:
The equation for the Weibull cumulative distribution function is:
]]>
Syntax:= VARPA (number1, [number2], …)
The VARPA function syntax has the following arguments:
Example: Let’s look at some Excel VARPA function examples and explore how to use the VARPA function as a worksheet function in Microsoft Excel:
Syntax: =VARPA(B2:B17)
Result: 2743.31
Note:
]]>
Syntax:= VARA (number1, [number2], …)
The VARA function syntax has the following arguments:
Example: Let’s look at some Excel VARA function examples and explore how to use the VARA function as a worksheet function in Microsoft Excel:
Suppose we are given data about the height of children from three cities, as shown below:
For variance, the formula used is:
Syntax: =VARA(B3:B14,D3:D14,F3:F14)
Result: 40.36
In the example above, we took the arguments for the VARA function as input in the form of three cell ranges. However, we can also enter the figures directly, either as individual numbers or number arrays.
For example, if you wanted to include two further heights, of 163cm and 155cm into the sample, you could add these directly into the above function as follows:
Either as individual numbers:
Syntax: =VARA(B3:B14,D3:D14,F3:F14,163,155)
Result: 39.06
or, as an array of numbers:
Syntax: =VARA(B3:B14,D3:D14,F3:F14,{163,155})
Result: 39.06
Note:
]]>
Editor: “I’d like you to write an article about the top five Excel functions accountants need to know.”
Me: “Hmm, the most common ones include SUM, IF, SUMIF, SUMIFS, or SUMPRODUCT; VLOOKUP (yuck!)
or INDEX(MATCH); OFFSET; MOD; and one of MAX and MIN — that will be a riveting read …”
Editor: “How about five powerful functions they should be using?”
Me: “That might be some of the new functions such as XLOOKUP, SORT, UNIQUE, FILTER, and SEQUENCE … I have written a lot about these recently, and besides, those are available only on Office 365, not Excel 2019, or Excel 2013, or Excel 2010, or …”
Editor: “OK, I get the point. How about the top five functions you should be using that have been around for a while and are accessible to standard Excel users?”
Me: “Good idea!”
There you have it. Dear reader, I present the top five functions that are available right now (and have been for some time) that you might not be using.
These are not necessarily your usual suspects, in alphabetical order.
You could argue this is the most complicated Excel function of all time. AGGREGATE began life in Excel 2010. For those who desire greater sesquipedalian loquaciousness (look it up), its syntax may give even more comfort, as it has two forms:
1. Reference: AGGREGATE(function_number, options, ref1, [ref2], …).
2. Array: AGGREGATE(function_number, options, array, [optional_argument]), where:
As already mentioned, AGGREGATE is analogous to an extension of the SUBTOTAL function insofar that it uses the same function_number arguments, adding another eight. SUBTOTAL allows you to use the 11 functions including/excluding hidden rows, which results in 22 combinations. However, AGGREGATE goes further and takes the 19 functions and allows for eight alternatives for each, which results in 152 combinations — and that’s not even considering the Reference or Array syntax approaches!
It just all sounds, well, tremendously complicated. This example Excel file helps demystify.
In practice, it’s not that bad. This is because, since this function was created, screen tips will appear as you type in order to nudge you in the right direction. For example, let’s say you wanted the third-largest number in the following list:
From inspection, the third-largest value is the amount in cell A2 (the value “5”), but if you use the usual formula for this = LARGE(A2:A10,3), you will get the value #REF!, as this is the first error that Excel comes across as it works down the list.
This is where you can use AGGREGATE to ignore these errors. If you type in =AGGREGATE(, you will get the following screen tip scroll list:
By typing “14” or selecting “14 – LARGE” from the pop-up list, you now know you are on the right track. After typing a comma, Excel then continues to help you:
Again, by either typing a number or pointing and clicking, an appropriate choice may be made. I want to ignore errors, so I need to choose “2”, “3”, “6”, or “7”, depending upon what else should be ignored. I will choose “6” — ignore error values only and then type another comma so that the screen tips keep coming thick and fast:
Now, Excel is seeking the references for evaluation. It appears to be possible that this can be in the form of a list (the array) or else discrete cell references and/or values. In this example, I will enter the range and type another comma:
Now, Excel appears to be looking for the other argument for LARGE() or else another reference. This is not correct. The screen tip does not update automatically. The syntax required is now just as it would be if we had typed in the underlying function, ie, =LARGE(array, k). In this instance, this syntax always requires the fourth value to be k, the integer denoting the kth-largest item in the list.
In this example, I will just type the value “3” and close brackets. Therefore, we arrive at the following formula:
=AGGREGATE(14,6,A2:A10,3)
which generates the correct answer “5”. The formula might look counterintuitive, but Excel has helped us every step of the way. As my oft-misquoted English teacher always used to say, practice makes perfect. Please see the attached Excel file for more examples.
To summarise, like SUBTOTAL, the AGGREGATE function is designed for columns of data (vertical ranges), not for rows of data (horizontal ranges). For example, when you subtotal a horizontal range using option 1, such as AGGREGATE(1, 1, ref1), hiding a column does not affect the aggregate sum value, although hiding a row in vertical range does affect the aggregate.
If a second ref argument is required but not provided, AGGREGATE returns a #VALUE! error.
If one or more of the references are three-dimensional references, AGGREGATE, like above, returns a #VALUE! error.
Dates are very important to accountants and should not just be hard-coded into a spreadsheet. We often need them to vary. We tend to work with month end dates, and this is where this function becomes invaluable. We usually run across one of the top rows in an Excel worksheet as part of a time series analysis:
In this example, a monthly model has been constructed starting in July 2020. The dates in cells J5 onwards are formatted to show only the month and year. However, if I were to format the cell as General instead (Ctrl+1), note that the Sample (circled in red) would be displayed as follows:
In other words, 31 July 2020 is no more than a number: 44,043. Microsoft Excel for Windows supports what is called the 1900 date system. This means that 1 January 1900 is considered to be day 1 by Excel, 2 January 1900 is day 2, and so on.
Clearly, dates are not as easy to manipulate as you might think. Extracting the day, month, or even the year from any given date is not straightforward because the date is really a number known as a serial number.
Extracting a day, month, or year requires using the following three functions:
It is just as awkward the other way around. If the day, month, and year are already known, the date can be calculated using the following function:
DATE(year, month, day) (for example, DATE(2020,7,32) = 1 August 2020, etc.).
Did you catch the function calculates the 32nd day of July as 1 August? Since dates are nothing more than serial numbers, they behave just like formatted numbers in Excel, for example, 31-Jul-20 + 128 = 6-Dec-2020.
This is all great, but time series still cause us problems. If we want to have the month end date in each column, we cannot simply take the previous month’s date and add a constant to it, since the number of days in a month varies. Fortunately, this is where EOMONTH comes in:
EOMONTH(specified_date, number_of_months)
The “End Of Month” (EOMONTH) function therefore calculates the end of the month as the number_of_months after the specified_date. For example:
Although the examples use typed-in dates, for it to work in Excel, it is best to have the specified_date either as a cell reference to a date or else use the DATE function to ensure that Excel understands it is a date (otherwise the formula may calculate it as #VALUE!).
In some instances (for example, appraisal of large-scale capital infrastructure projects), the dates may need to be for the same day of the month (for example, the 15th) rather than for the month end. A function similar to EOMONTH, EDATE can be used instead:
EDATE(specified_date, number_of_months).
The “Equivalent day” (EDATE) function therefore calculates the date that is the indicated number_of_months before or after the specified_date. For example:
If an equivalent date cannot be found (as in the last example), month end is used instead.
New to Excel 2013, this is one of the most used functions by my team. It’s a really useful tool for documenting formulas, as FORMULATEXT returns a formula as a text string. People have been writing User-Defined Functions (UDFs) for years to replicate this functionality.
In fact, if you have ever downloaded one of my example workbooks, the chances are you have analysed a formula described using the FORMULATEXT function:
The expressions in cells G8 and G9 (above) are both provided by the FORMULATEXT function. For example, the formula in cell G8 is:
=FORMULATEXT(E8).
The FORMULATEXT function employs the following syntax to operate:
FORMULATEXT(reference)
It has the following argument:
It should be further noted that:
I love this example:
I love functions I can spell. The N function returns a value converted to a number. It has only one argument:
N(value)
The value argument is required and represents the value you want converted. N converts values on the following basis:
Usually, you don’t need to use the N function in a formula because Excel automatically converts values as necessary. Microsoft states that this function is provided for compatibility with other spreadsheet programs. However, I disagree: I use this function all the time. Let me explain.
Counters are often used in financial modelling, eg:
It’s not a good idea to type these numbers in and/or use AutoFill. This is because if an end user wishes to extend the sequence, they might take the first cell (D2) and drag it across. Unfortunately, in this scenario, you would get a sequence of 1’s, viz.
Oops. Therefore, we should use a formula in cell D2 such as =C2+1:
That’s all well and good, until someone types something in cell C2:
The problem is cell C2 now contains text, and you cannot add one (1) to text. However, you can add N to the formula:
The N function ignores the text in cell C2. That’s exactly what we require. I use counters in my financial models all the time — and, therefore, I use the N function all the time, too.
The TEXTJOIN function combines the text from multiple ranges and/or text strings and includes a delimiter to be specified between each text value to be combined. If the delimiter is an empty text string, this function will effectively concatenate the ranges similar to the CONCAT function. Its syntax is:
TEXTJOIN(delimiter, ignore_empty, text1, [text2], …)
where:
TEXTJOIN is more powerful than CONCAT. To highlight this, consider the following examples:
Here, in the formulas on rows 53 and 54, empty cells in a contiguous range may be ignored, and delimiters only need to be specified once. It’s a great way to create lists for reporting, for example.
]]>