Wednesday, October 25, 2017

Using the COUNTIF function in Excel: Beginner to Advanced

The COUNTIF Formula is used to count the number of cells that match a specific condition. It's hands down a game changer of a formula because at it's very basic it can give you some basic stats on data but as you'll see when we delve deeper that as the level of sophistication improves so does it's power at analysing.

But...let's start at the basics, the Formula itself is entered as

and is found under the FORMULAS tab in the Ribbon. Click More Functions, select Statistical and scroll down to COUNTIF.

The range entered will be the area in which Excel will search for the condition and may be manually entered or entered by highlighting the area within the worksheet that contains the data.

Conditions set by the user could be an exact wording match, counting the cells that match an individual cell, could be multiple conditions, or it could be a greater than, less than, or in between condition. The COUNTIF Function is useful to quickly count the number of customers in a geographic region or find how many types of inventory one has or even find how many products are currently being sold at a price between $1.00 and $5.00. 

Consider the following worksheet as we delve into the various conditions used within the COUNTIF Function.

various countif function
Counting Cells with an exact wording match

If you wanted to know how many Projects are Renovation Projects you could easily scan hundreds of projects at once by entering the formula into any unused cell, typing 

Keep in mind that conditions are not case sensitive. Entering in “renovation” will yield the same result.

The range for this example could be the entire worksheet or in this case we are searching down the second column to count how many times “Renovation” is entered and the range could be narrowed down to just that column. The result in this instance would be 4. This condition works successfully if all data is accurate and consistent.

Counting Cells that Match

If you wanted to know how many Projects are located in New York City you could use the same formula as above and type in “New York City” as the condition or you can click on a Cell that contains the word “New York City” which in this case is A2 and Excel will match all other cells and total the findings. This formula would be entered into any unused cell as =COUNTIF(A2:C9),A2) hit enter and the result will yield a 2. 

Counting Cells using a Greater Than or Less Than Formula

To find the number of Projects that cost more than $10,000 use the formula,

Be sure to enter the quotes before and after the condition and then close out the parenthesis. The result will be 5 in this case. Similarly, if the desired result is for all items priced equal to or greater than $10000 the condition would be entered as “>=10000” resulting in a value of 6.

The less than formula is the same as the greater than formula except the condition would be entered as “<10000” or for less than or equal to “<=10000”.

This formula could also be written with a match cells formula instead of the exact wording. =COUNTIF(A2:C9,”>”&C5)

The operator (>) must be enclosed in quotes and immediately followed by the ampersand sign then the cell that contains the data, in this case C5.

Counting Cells in between two values

Should you want to locate the total Projects that have a price range of $10,000 to $20,000 the formula would be:

that is excel is searching for all items equal to or greater than $10,000 and subtracting all items greater than $20,000 to show only those items with prices ranging from ten to twenty thousand.

Counting Cells that do not equal a specific amount

Say we wanted to find the number of Projects within the United States. We do not have a Column that lists the Country the Project will be completed in but we can quickly see that the only city outside of the United States is London. We can now use the formula to find the total number of Projects that are NOT in London by entering 

The end result is 7 Projects within the United States.
Building off the original worksheet from here on let’s continue with the following data

Seven Project

Using wild cards

Notice in the worksheet that Project Type is usually written out as Renovation, however, in Row 9 it is written as “Reno”. Inconsistent data is all too common in large spreadsheets making it impossible to count the number of Renovation Projects by using either the exact wording match or the match cells conditions used earlier. If the data is inconsistent Wild Cards may be utilised.
The first wild card is the asterisk (*) The asterisk is used to find cells that have the same beginning or ending characters. To find the number of Renovation Projects enter:

this formula is telling Excel to search Column B for any Projects that begin with “Reno” and under the Counts total in the above screenshot the number is 4.

The second wild card character is the question mark (?). The question mark is used if you need to find the count of cells that you know either begin with or end with specific letters or numbers and have an exact same amount of characters. To see the total Projects in London you could enter the exact wording match, match cells or you could enter:

With this Excel will search for any 6 letter words ending in ON within Column A. Should your data have an asterisk or question mark within the cells the COUNTIF Formula can still be used by inserting a tilde (~) in front of the question mark or asterisk in the formula. Excel will then treat the question mark or asterisk as an actual character versus a wild card.

Multiple Conditions

Using the addition sign (+) tells Excel to search for more than one condition.
To determine the number of permits that must be completed during the fourth quarter, enter:

Telling Excel you want the total count for all Permits with a due date of October, November and December. Out of the 6 permits due, 4 are due within the 4th Quarter.

Working with dates using the COUNTIF Function

The formulas that have already been mentioned will work the same using dates. Plus you can combine the COUNTIF Function with Excel Date and Time functions to find the number of projects that have already started as of today, the number of projects that have not started as of today or the number of projects that started in the first quarter. Using the Start Date data we enter those formulas using the TODAY() Formula as such:

Number of Projects that have not started as of today =COUNTIF(C2:C11, ">"&TODAY()) Showing 3 Future Projects.

Number of Projects whose Start Date has passed =COUNTIF(C2:C11,"<"&TODAY()) Showing 7 Past or Present Projects.

To find dates within a specific range utilise the Counting Cells in between two values formula as previously mentioned and enter the dates as the values. For all Projects with a Start Date during the first quarter:

Showing 7 total Projects started during the first quarter.

Using COUNTIF Function to help clean up data

To find the number of mistakes within a worksheet without having to scroll through all the data you could utilise COUNTIF Functions to check for mistakes.

Finding missing data:

The formula above lists all blank cells within the entire worksheet, however, by searching each column one at a time you can skip over the columns without blank cells. Go through the columns that yield a count of blank cells and enter in the appropriate data. Likewise, removing the asterisk from the equation will provide the total number of cells that are not blank.

Finding duplicate data:

COUNTIF can find duplicates within one or multiple columns and rows. For example, let’s assume the company never has a project start on the same day. Search the worksheet for repeat dates. The simplest way is to add a column to the worksheet titled duplicates. The formula to test for duplicates is:

Excel is Searching all of Column C for any date that matches the date in C2. Repeat this process down the Duplicate column and any TRUE values can easily be located as duplicates. The result shows a duplication of C5 and C12. To quickly search for the TRUE values, Sort the data in Column E from Z to A and all duplicates will be at the top of the worksheet. If necessary, all duplicates can be deleted.

To get a total of all duplicates enter:

Now, i'm about to get a lot more complicated but just trust the formula! Let's Count duplicates in multiple columns, we enter the following:

This results in a 1 showing one single duplicate between Column A and B. That duplicate is Tampa accidentally being entered as the Project Type and can easily be remedied. This same duplicate could have been found by searching for duplicates within a row by entering:

Repeat for each row to find any duplicates within the rows.

Hopefully, these examples on how to utilise the COUNTIF Function have shown the wide array of uses. If you run into any problems with the formulas be sure to check the following common mistakes.

• Make sure there are no spaces between any characters in the formula
• Double check that the parentheses have been closed
• Ensure the operators are enclosed in quotations

I hope you found the article useful, let me know if you have any questions and before you head, sign up below for my free book 'The only 27 Formulas a professional needs to know'. 

Sohail

The post Using the COUNTIF function in Excel: Beginner to Advanced appeared first on Earn and Excel.

Monday, October 23, 2017

How to Make a Pie Chart in Excel 2010

I’m a big fan of Pie Charts because they are a great visual representation of ‘spread’ or ‘distribution’ of data. By this I mean you can understand how different parts contribute to the whole. Rather than throw more fancy words at you, here’s a few visuals to explain further:

You want to depict the Mobile Phone market share, taking some numbers from 2016 we get:

The option to include or exclude numbers from Pie Charts is useful depending on whether you are aiming to show deep analysis in your reports or spark conversation.

Another example would be a Pie Chart that belongs on a Project Management dashboard to show the distribution of Red, Amber and Green rated projects. Now we don’t have to have numbers, but the visual can set the tone for a meeting that will be discussing the progress of the projects.

Enough banter on Pie Charts, how do we actually make them?!

To generate a pie chart in MS Excel 2010, execute the following 3 steps.

I'm going to randomly pick the topic of Nepalese ethnic groups to build our Pie Chart. Enjoy!

1. Start by listing the data in a worksheet as in the picture below. This is pretty easy, one order can be your forms of the ethnic groups, and one other order is their corresponding percentage.

For example, to create a spreadsheet featuring the percentage of ethnic groups and the percentage you are able to write “Newar” in cell C7 and "30" in cell D7 and so on. Please note: All data values are more than zero and you will find no clear lines or columns.

Click to enlarge

2. Now pick the data you want to be represented in the pie chart: To select the data, click the top left of the effective data and then pull the cursor to the bottom right. In this case, I have selected the data range C7: D12

Click to enlarge

3. And once everything is selected, Click the Insert ribbon and then Click Pie, then pick the basic 2-D option (3-D versions have the potential to cause confusion in audiences so stay away from them) and voila! A pie chart will be automatically placed into your worksheet.

Click to enlarge

As ever with Excel if you happen to change any of the data, that change will ripple through automatically in to the Pie Chart.

Let's look at some of the customisation options for the Pie Chart

Customise the Pie chart from the Design tab

Whenever you click the pie chart you will be shown the 'Chart Tools' menu on the ribbon. The three tabs being: Design, Layout and Format.

Click to enlarge

Next Click on the "Design" tab under Chart Tools to see the Chart Styles cell and Chart Layout panel. Several style types can be seen in a drop down box when clicked. You can search up and down through the alternatives and find something suitable for your report/dashboard. In the case, I've picked the Layout 6. 

Click to enlarge

Similarly, you are able to press the "Format" tab in the Chart Tools element of the ribbon. Select "Shape Fill," "Shape Outline" or "Shape Effects" to decide on the visuals of the pie chart. In the figure, I’ve selected the second shape styles..

Click to enlarge

Adding Labels to your Pie Chart

If you need more customisation for the pie chart, Right-click the chart and select "Format Data Labels." A pop-up dialogue box starts featuring the label options. Select "percentage" to see the values indicated as a percentage of the entire pie chart, or select "value" to alter the phase labels to their numeric values as shown in the spreadsheet.

You can select or deselect some other labelling possibilities to suit your preferences. As an example, checking "Series Name" or "Category Name" includes these names to the phase labels. Choosing one of the Label Position possibilities changes where the phase labels appear. In the example, I've selected the Category name in the label options.

Click to enlarge

Thanks for reading!

Before you go, get my report '10 things I did with Excel that increased my salary from £27K to £100K'

The post How to Make a Pie Chart in Excel 2010 appeared first on Earn and Excel.