How to Add a Target Line to an Excel chart

Today, we want to learn how to add a Tar­get Line to our chart and con­trol it. 

How to Add a Tar­get Line to an Excel chart

Some­times, we want to low­er the line, some­times we want to raise it. But, firs things first. 

Let’s start with writ­ing the tar­get. Let’s write 700. Then, we have to cre­ate a sim­ple for­mu­la with­out any dol­lars in the first cell below (Fig. 1)

=C2

A simple formula
Fig. 1 A sim­ple formula

Now, we can copy the for­mu­la down. And what’s hap­pened? Each cell is refer­ring to the cell above it. At the end, they are going to the first cell (Fig. 2)

 Each cell refers to the cell above
Fig. 2 Each cell refers to the cell above

It means that when we change the val­ue in the first cell, the val­ues in the cells below also change (Fig. 3)

Values changed
Fig. 3 Val­ues changed

Now, when our data is prop­er­ly pre­pared, we can select the whole data, go to the Insert tab (1), then go to Charts and choose the col­umn chart option (2) (Fig. 4)

Creating a chart
Fig. 4 Cre­at­ing a chart

We have a chart but no line. To cre­ate one, we have to select the Tar­get series, go to the Insert tab (1), and choose a line chart from the Charts area (2) (Fig. 5)

Creating a line
Fig. 5 Cre­at­ing a line

When we have the line, we can right-click it and choose the Change Series Chart Type option from the pop-up menu (Fig. 6)

Changing the chart type
Fig. 6 Chang­ing the chart type

In the win­dow that has appeared, we can change the chart type to any we like (Fig. 7)

Chart type options
Fig. 7 Chart type options

How­ev­er, we have already cho­sen the type we want­ed. Let’s change the val­ue in the first cell in the Tar­get col­umn. What we can see is that the line has changed its posi­tion (Fig. 8)

Value change
Fig. 8 Val­ue change

We can also cal­cu­late the aver­age of our data using the AVERAGE func­tion (Fig. 9)

=AVERAGE(B2:B13)

Calculating the average
Fig. 9 Cal­cu­lat­ing the average

Now, we have an aver­age line for our data (Fig. 10)

 An average line
Fig. 10 An aver­age line

https://www.youtube.com/watch?v=w5cwLRB-YyY

Named ranges and statistics

Some­times, we need to make many sta­tis­ti­cal oper­a­tions and use many sta­tis­ti­cal func­tions in Excel. How can we do it?

Named ranges and statistics 

A fast and quick solu­tion is using name ranges. For exam­ple, we have the SUM func­tion that sums up all val­ues from Jan­u­ary (Fig. 1)

SUM function
Fig. 1 SUM function

How can we name ranges and use them for our advan­tage? Let’s start with a sim­ple exam­ple of the SUM func­tion. For the SUM func­tion, we have key­board short­cut which is Alt + =. This way Excel will put the sum for Jan­u­ary, which is a range form B2:B6 (Fig. 2)

=SUM(B2:B6)

Alt + = to put the sum
Fig. 2 Alt + = to put the sum

In the exam­ple above we had num­bers. How­ev­er, let’s go to anoth­er sheet where we have no num­bers. When we want to sum the num­bers from the pre­vi­ous sheet, it’s going to be a very tedious job, as we have to move between those two sheets and write prop­er val­ues. What’s more, the ref­er­ence we have while using val­ues form anoth­er sheet isn’t the eas­i­est to under­stand. What we can do is nam­ing the ranges. We just have to select a range in a col­umn and write a prop­er name in the Name Box (Fig. 3).

Naming the range
Fig. 3 Nam­ing the range

Now, when we are using the Alt + = short­cut under our val­ues, Excel will auto­mat­i­cal­ly refer to the Jan­u­ary range, which is B2:B6 (Fig. 4)

=SUM(Jan­u­ary)

Automatic reference
Fig. 4 Auto­mat­ic reference

As we know, Excel remem­bers names. It means that we can use the name in cal­cu­la­tion on a dif­fer­ent sheet. When I start writ­ing “ja” in anoth­er sheet, Excel will sug­gest the range name (Fig. 5). I can just accept it and sum the val­ues from January. 

Excel suggested the range name
Fig. 5 Excel sug­gest­ed the range name

As we can see, nam­ing ranges makes our work faster. We can also name a big­ger group of columns at one time. Just select the group you want. What’s impor­tant, when you’re select­ing your data, you have to select the top rows, and then the num­bers beneath them. Then, go to the For­mu­las tab, click on the Cre­ate from Selec­tion com­mand and select the Top Row check­box in the win­dow that appeared (Fig. 6)

Creating names from selection
Fig. 6 Cre­at­ing names from selection

Now, after we named our ranges, we can see that the Feb­ru­ary range is named Feb­ru­ary, the March range is named March and so on. When we move to anoth­er sheet, we can use those names (Fig. 7)

Excel is suggesting the new names
Fig. 7 Excel is sug­gest­ing the new names

How­ev­er, we can go one step fur­ther using the ref­er­ence to names. I have Jan­u­ary in cell B1. But, when I refer to cell B1, Excel won’t sim­ply con­vert the text from cell B1 to a range because it just text. It means that our func­tion won’t add any­thing. First of all, we have to lock the rows (B$1), then add the INDIRECT func­tion to our cal­cu­la­tion. Now, the INDIRECT func­tion changes the text into a ref­er­ence to the prop­er range (Fig. 8)

=SUM(INDIRECT(B$1))

INDIRECT function
Fig. 8 INDIRECT function

Now, when I drag the for­mu­la to the right, I will have sums from each indi­vid­ual month (Fig. 9)

=SUM(INDIRECT(F$1))

Sum from individual months
Fig. 9 Sum from indi­vid­ual months

When I copy the for­mu­la one cell low­er, I’m just chang­ing SUM into AVERAGE (Fig. 11)

=AVERAGE(INDIRECT(B$1))

SUM into AVERAGE
Fig. 1 SUM into AVERAGE

After I drag it to the right, I have prop­er results. I do the same with the remain­ing rows (Fig. 12)

=MIN(INDIRECT(B$1))

Changing the remaining names
Fig. 12 Chang­ing the remain­ing names

This way, we can quick­ly add more sta­tis­ti­cal oper­a­tions for many months using prop­er name ranges and the INDIRECT function. 

https://www.youtube.com/watch?v=E9APUsy4y‑E

SUM and AVERAGE with condition — SUMIF and AVERAGEIF functions

Today, we are going to count sums and aver­ages with con­di­tions. In our first exam­ple, we have a small table where we sell fruit. We want to sum up the whole weight and aver­age weight for a sin­gle cell. To sum the val­ues with con­di­tions we can use the SUMIF func­tion. In the first argu­ment, we write the range where we need to check our con­di­tion and lock it by press­ing the F4 key. In the sec­ond argu­ment, which is cri­te­ria, we just put a ref­er­ence to a sin­gle cell with the prod­uct name. We don’t have to lock the cell because while copy­ing the for­mu­la down, we want the fruit names to change. The third argu­ment of the func­tion is the sum range. It is closed in square brack­ets which means that it is not nec­es­sary write it, how­ev­er we will do it. We want to sum val­ues from the Weight col­umn. Then the F4 key to lock it (Fig. 1).

SUM and AVERAGE with con­di­tion — SUMIF and AVERAGEIF functions

=SUMIF($B$2:$B$10,F2,$C$2:$C$10)

 SUMIF function
Fig. 1 SUMIF function

After all argu­ments have been writ­ten, let’s look at our ranges and try to under­stand how the SUMIF func­tion works. The func­tion will look at each cell in the Prod­uct col­umn and check if they meet the con­di­tions. In the first cell, we have apples, which means that the con­di­tion is met. In such a sit­u­a­tion, the func­tion will keep on look­ing for the third argu­ment placed in the same row. If it finds it, it will add the val­ue. If there is anoth­er cell that meets the same con­di­tion, it will also add the val­ue from the same row (Fig. 2).

Finding conditions
Fig. 2 Find­ing conditions

Our for­mu­la looks as fol­lows (Fig. 3).

=SUMIF($B$2:$B$10,F2,$C$2:$C$10)

SUMIF formula
Fig. 3 SUMIF formula

After enter­ing and copy­ing down, we can see how many apples, pears and oranges we have sold (Fig. 4).

Results
Fig. 4 Results

Now, let’s try to count the aver­age weight of a sin­gle sale. We just have to copy our SUMIF for­mu­la in the edit mode and paste it into the cell in the Aver­age col­umn. The SUMIF and the AVERAGE func­tions have the same argu­ments. We just change the func­tion name. We can see that the name of the third argu­ment changed from sum range into aver­age range, how­ev­er it is still the same Weight col­umn (fig. 5).

=AVERAGEIF($B$2:$B$10, F2,$C$2:$C$10)

Name change
Fig. 5 Name change

After enter­ing and copy­ing it down, we have our results (Fig. 6).

Fig. 6 AVERAGEIF counted

Let’s move on to our sec­ond exam­ple. We want to check here what would hap­pen if we give the AVERAGEIF or SUMIF func­tion just two argu­ments. In this exam­ple, we just want to count the aver­age sale. We are start­ing with a sim­ple AVERAGE func­tion with­out con­di­tions, so with­out IFs, for the Sales col­umn (Fig.7).

=AVERAGE(C2:C11)

Simple AVERAGE function
Fig. 7 Sim­ple AVERAGE function

After enter­ing it, we have the aver­age (Fig. 8). 

Average
Fig. 8 Average

Now, let’s count the aver­age with a con­di­tion. We don’t want to count the val­ue if it equals 0. Let’s write the AVERAGEIF func­tion, select the same range and write the con­di­tion. We open dou­ble quotes and write <>0 and close it. When we don’t write the third argu­ment in the AVERAGEIF or SUMIF func­tions, Excel takes the first range as the range in which we are doing our cal­cu­la­tions. In this sit­u­a­tion Excel does­n’t take emp­ty cells and cells with 0 into cal­cu­lat­ing the aver­age. After enter­ing it, we can see dif­fer­ent results. It’s because our con­di­tion was trig­gered in the AVERAGEIF func­tion, which means that Excel did not count the cells with 0 (Fig. 9). 

Different results
Fig. 9 Dif­fer­ent results

When we delete the val­ue with 0, we can see that the AVERAGE and AVERAGEIF func­tion return the same results. It’s because func­tions such as AVERAGE, SUMS, MIN and MAX do not con­sid­er emp­ty cells (Fig. 10).

Results without empty cells
Fig. 10 Results with­out emp­ty cells

How­ev­er, when we put 0 into the cells, the AVERAGE func­tion will count it which means that the aver­age will go down (Fig. 11).

Fig. 11 Results with zeros

Sum­ming up, a sim­ple AVERAGE func­tion counts cells with 0, and the AVERAGEIF func­tion does­n’t due to the condition. 

In Excel, in most sit­u­a­tions, emp­ty cells are treat­ed as 0. 

https://www.youtube.com/watch?v=5h7hVwUjoWA