Target Chart with Unique targets 

Today, we want to learn how to cre­ate a chart on which we have unique tar­gets for each month, group, shop, etc. 

Tar­get Chart with Unique targets

The most impor­tant task for us is to cre­ate prop­er data. When we do it in the right way, the rest will be much sim­pler. Let’s start with cre­at­ing a Base series, which will be the foun­da­tion of our chart. We have to check if the income is larg­er than the tar­get. It means that we have to make a log­i­cal test with the IF func­tion. If it’s cor­rect, we want the small­er val­ue, which is the tar­get val­ue. In the oth­er case, we want the income (Fig. 1)

=IF(B2>C2,C2,B2)

IF function for the Base series
Fig. 1 IF func­tion for the Base series

And just like that, we have our foun­da­tion. Now, we can move on to the next step. If the income is larg­er than the tar­get, we want to know how much larg­er it is. We will cre­ate it in the Upper col­umn. We start with the IF func­tion again, and we are check­ing if the income is larg­er than the tar­get. If so, we want to deduct the tar­get from the income. In the oppo­site case, we want noth­ing, i.e. we want our chart to show noth­ing. It means that we can­not write just an emp­ty text string in the for­mu­la in two dou­ble quotes. We have to return an error. The sim­plest way I know is using the NA func­tion (Fig. 2)

IF function for the Upper series
Fig. 2 IF func­tion for the Upper series

And just like that, we have our Upper series. The last thing to do is the Low­er series. It is very sim­i­lar to the pre­vi­ous for­mu­la, All we need to change is the ‘larg­er than’ sign into ‘small­er than’ sign, and deduct the income from the tar­get (Fig. 3)

IF function for the Lower series
Fig. 3 IF func­tion for the Low­er series

Just like that, we have the sec­ond series. 

Now, when we have a val­ue in one of the Upper cells, we will have an error in the same row in the Low­er cell, and vice ver­sa. When our data looks OK, we can move on to insert­ing a chart. We have to select the Months col­umn, as well and the Base, Upper and Low­er series. Then, we go to the Insert tab (1), then to the bar chart, where we select the Stacked Column option (2) (Fig. 4)

Creating a stacked column
Fig. 4 Cre­at­ing a stacked column

Now, we have all we need. We have our Base. When our income is larg­er than the tar­get, we have a blue part, and when we did­n’t reach the tar­get, we have green. Let’s change the col­ors, so that the dif­fer­ences are more vis­i­ble. I also don’t like the hor­i­zon­tal lines, so let’s delete them by select­ing them and click­ing the Delete key. I will also widen the columns by select­ing them and press­ing Ctrl + 1. In the For­mat Data Series win­dow on the right we can change the Gap Width to 70% (Fig. 5)

Gap Width option
Fig. 5 Gap Width option

Now, I want to add our tar­get. Since we have only col­umn charts here, we can copy our tar­get col­umn, select the chart and press Ctrl + V. Now, we have our tar­get, how­ev­er, we don’t want to have anoth­er col­umn. We can change it into a line chart with marks. We can do it by right-click­ing on the tar­get series in the chart. In the pop-up menu, we have a Change Series Chart Type option (Fig. 6)

Change Series Chart Type option
Fig. 6 Change Series Chart Type option

In the Change Chart Type win­dow, we can change our tar­get by click­ing on prop­er options (Fig. 7)

Line with Markers option
Fig. 7 Line with Mark­ers option

How­ev­er, there is one more option. We can go to the Insert tab, and when the series is select­ed, we choose a prop­er chart. The result is the same (Fig. 8)

Line with Markers option
Fig. 8 Line with Mark­ers option

Now, we have to select our line with mark­ers, then press Ctrl + 1 to open the For­mat Data Series win­dow. When our line chart is select­ed, we have to go to the buck­et part, and select the No line option in the Line part (Fig. 9)

No line option
Fig. 9 No line option

In the Marker part, we can use some built-in mark­ers, like a line. How­ev­er, when I’m using the line, it’s too thick for me, espe­cial­ly in a big­ger size (Fig. 10)

 Bigger size
Fig. 10 Big­ger size 

In such a case, we can do anoth­er trick. Let’s go to the Insert tab (1), then the Shape part (2), and select a sim­ple Line (3) (Fig. 11)

Line option
Fig. 11 Line option

Now, while hold­ing the Shift key, we can draw a line with our mouse (1), and mod­i­fy it (2) (Fig. 12)

Line modification
Fig. 12 Line modification

Now, we can copy the line, then select mark­ers and paste it. I can see that my line isn’t long enough, so i’ll just make it longer, then paste it once again (Fig. 13)

Longer line
Fig. 13 Longer line

Now, let’s insert data labels. In the Chart Ele­ments win­dow we have to select the Data Labels option. Excel,then will give me data labels for each series (Fig. 14)

Chart elements window
Fig. 14 Chart ele­ments window

How­ev­er, I don’t want data labels for the tar­get series, so I have to select it and just delete it. Now, It’s impor­tant that we have data labels for our upper part only when there is an upper part. In places with errors, there won’t be data labels. The same is with low­er parts. Errors won’t show any­thing on the chart. Let’s change low­er data label col­or by going to the Home tab and select­ing white (Fig. 15)

Color change
Fig. 15 Col­or change

Let’s add the chart title. Let it be the con­tend of cell B1. We write = in the for­mu­la bar, then click the cell and press Enter (Fig. 16)

=‘E061’!$B$1

Chart title
Fig. 16 Chart title

There is one more thing. I some­times don’t want to show the tar­get series in the leg­end. To remove it, we have to click on the leg­end, then once more on the tar­get series in the leg­end, then press Delete (Fig. 17)

Final chart
Fig. 17 Final chart

Now, I’m hap­py with my chart with unique tar­get for months, groups, shops, etc. 

https://www.youtube.com/watch?v=_UmfRhNT9v4&t

Bankers Rounding (Half-Way-Even) to Dollars, Pennies and Hundreds

Today, we are going to talk about bank round­ing, or half-way-even rounding.

Bankers Round­ing (Half-Way-Even) to Dol­lars, Pen­nies and Hundreds

In a clas­sic Excel round­ing, if we have 5 as the most sig­nif­i­cant num­ber for us, we always go up. It means that errors go up. To make the dis­tri­b­u­tion of our round­ings a bit more even, we some­times need to go down. That’s why we have the bank round­ing which goes around the near­est, even num­ber. Let’s take the num­ber of 7.50. Our whole num­ber, which is 7, is an odd num­ber. By round­ing up, we go to the near­est, even num­ber, which is 8. How­ev­er, if our whole num­ber is even, like in 8.50, we go down to 8. The dis­tri­b­u­tion of the round­ing val­ues is more even, which means that an error is less sig­nif­i­cant. It’s impor­tant espe­cial­ly in bank­ing, that’s why we call it bank round­ing (Fig. 1)

Rounding to the nearest, even number
Fig. 1 Round­ing to the near­est, even number

How can we use it in Excel, when we know that the stan­dard ROUND func­tion will always go up if the most sig­nif­i­cant num­ber is 5. The answer is that we have to cre­ate a dif­fer­ent for­mu­la. The for­mu­la that works for me, where I haven’t seen any errors is a bit com­pli­cat­ed, how­ev­er, when we start work­ing with this, it will be quite easy to under­stand. First, we have to check whether our num­bers are half way or not. We can see that two num­bers are half way. In the remain­ing ones, the sit­u­a­tion is clear, i.e. we know that we want to go up or down (Fig. 2)

Halfway numbers
Fig. 2 Halfway numbers

If we want to check whether to go up or down, we can use the MOD func­tion, where we should write 1 to check what the divider is, i.e. we want to check what is the rest after divid­ing it by 1 (Fig. 3)

=MOD(A2,1)

MOD function
Fig. 3 MOD function

We can see the results (Fig. 4)

MOD function results
Fig. 4 MOD func­tion results

If the num­ber is halfway, we need to round it to the near­est whole num­ber. It means that we have to check whether the result of the MOD func­tion is equal to 0.5. If it is, we should use the MROUND func­tion that returns the desired num­ber round­ed to the desired mul­ti­ply of even num­bers from our exam­ple. It means that we want to round 207.50 to the near­est mul­ti­ply of even num­bers, which is 2. In oth­er cas­es, we just use the ROUND func­tion to whole num­bers. In our case, the num­ber of dig­its is 0 (Fig. 5)

=IF(MOD(A2,1)=0.5,MROUND(A2,2),ROUND(A2,0))

Proper formula
Fig. 5 Prop­er formula

Look­ing at the results, we can see that when we have an odd, whole num­ber and we are halfway, we go up to the near­est even num­ber. If we have an even num­ber and we are halfway, we go down to the near­est, even num­ber. How­ev­er, if we pass the halfway thresh­old, we start to go up (Fig. 6)

Even and odd numbers in data
Fig. 6 Even and odd num­bers in data

Now, let’s go to the round­ing to 100. We copy our pre­vi­ous for­mu­la, which aimed at round­ing to whole num­bers. Now, we want to round to 100, which is 100 times more than in the pre­vi­ous exam­ple. It means that we have to mul­ti­ply all num­bers in our for­mu­la by 100 (Fig. 7)

=IF(MOD(E2,100)=50,MROUND(E2,200),ROUND(E2,-2))

Multiplication by 100
Fig. 7 Mul­ti­pli­ca­tion by 100

And just like that we have prop­er results. We went halfway in two cas­es. Since we’re round­ing to 100, we went up in the num­ber 2350. In the sec­ond halfway num­ber, which is 2450, we already had an even num­ber, so we went down to the near­est even num­ber (Fig. 8)

Rounding to 100
Fig. 8 Round­ing to 100

If I change num­bers in the last exam­ple and pass the halfway thresh­old, we can see that the round­ing goes up (Fig. 9)

Rounding goes up
Fig. 9 Round­ing goes up

If we want to use the bank round­ing to dec­i­mal places, e.g. for pen­nies, it will be a bit more prob­lem­at­ic. Here, we have to remem­ber that we are check­ing the sec­ond dig­it to know whether it’s an even val­ue. If the dig­it is odd, we round up, and if the num­ber is even, we go down to the near­est even num­ber. We have to remem­ber that if we pass the halfway thresh­old, we start to go up (Fig. 10)

Rounding with decimal places
Fig. 10 Round­ing with dec­i­mal places

If we want to work with this banker’s round­ing rule with dec­i­mal places, we can­not use the MOD func­tion because, when we work with e.g. pen­nies, the MOD func­tion results will have some inac­cu­ra­cies in dig­its that are far away, like on the fif­teenth place after the dot, or so. In such a sit­u­a­tion we won’t be able to check whether it is halfway, because the far places show that it’s not (Fig. 11)

Inaccuracies in digits
Fig. 11 Inac­cu­ra­cies in digits

When we work with whole num­bers, we can use the MOD func­tion because they are pre­cise. A num­ber in halfway will be returned by the MOD func­tion as still a halfway num­ber. In some oth­er sit­u­a­tions there can be some inac­cu­ra­cies, but they don’t con­cern us, because they will work cor­rect­ly. Here, we care only about halfway num­bers, which stay halfway in the MOD func­tion (Fig. 12)

The MOD function with whole numbers
Fig. 12 The MOD func­tion with whole numbers

In the case of pen­nies, we have to use a dif­fer­ent method. This method will show the num­ber of dig­its we want to have. Let’s assume that we want to have five dig­its after dot. In such a case, we have to change our num­ber to text by using the TEXT func­tion, where we write the for­mat num­ber as 0.00000 (Fig. 13)

=TEXT(H2,“0.00000”)

Changing numbers into text
Fig. 13 Chang­ing num­bers into text

Just like that we have num­bers as text, but with five-dig­it pre­ci­sion. Now, let’s look for halfway num­bers. We can see that halfway is 500 as the last three dig­its (Fig. 14)

Numbers with five-digit precision
Fig. 14 Num­bers with five-dig­it precision

Now, we have to take out those three dig­its. Since they are locat­ed on the right side, we can use the RIGHT func­tion, where we write 3 (Fig. 15)

=RIGHT(TEXT(H2,“0.00000”),3)

The RIGHT function taking out the last five digits
Fig. 15 The RIGHT func­tion tak­ing out the last five digits

And just like that we have only three, last dig­its. When we are in halfway, we will have exact­ly 500. Here, we also have to remem­ber about dif­fer­ent round­ings. If the num­ber before 500 is odd, we go up, but then it’s even, we go down (Fig. 16)

Three, last digits
Fig. 16 Three, last digits

We have to check whether the num­ber is equal to 500 using the IF func­tion. We have remem­ber that we are work­ing with text, so we need to write 500 in dou­ble quote. Then, we can sim­ply use the MROUND func­tion, just like in pre­vi­ous exam­ples, but this time our mul­ti­ply isn’t 2, but 0.02. If we aren’t halfway, we can sim­ply round our val­ues using the ROUND func­tion (Fig. 17)

=IF(RIGHT(TEXT(H2,“0.00000”),3)=“500”,MROUND(H2,0.02),ROUND(H2,2))

The IF function
Fig. 17 The IF function 

We can see that the round­ing went up when the sig­nif­i­cant num­ber was odd, and the round­ing went down when the sig­nif­i­cant num­ber was even. When we passed the halfway thresh­old, we start­ed round­ing up. We have a for­mu­la that works with dec­i­mal places and the banker’s round­ing, how­ev­er, we have to remem­ber about our assump­tions. We set the pre­ci­sion to five dig­its, but only the last three of them are impor­tant for us. Based on the last three dig­its, the round­ing uses the MROUND or the ROUND func­tion (Fig. 18)

Results
Fig. 18 Results

https://www.youtube.com/watch?v=kUOXZFXwPzw

Is this Time between Working Hours

How can we check whether the giv­en time is between the work­ing hours or not?

Is this Time between Work­ing Hours 

In our case, work starts at 9:30 AM, and ends at 5:30 PM. Our giv­en time, which is 6:47 isn’t between the work­ing ours. When we change it, we can see that the col­or changed into red and ‘No’ turned into ‘Yes’, which means that now the time is between the work­ing ours (Fig. 1)

Our given time is between the working hours
Fig. 1 Our giv­en time is between the work­ing hours

How­ev­er, when we go to ear­li­er hours we can see that the details changed (Fig. 2)

 Our given time isn't between the working hours
Fig. 2 Our giv­en time isn’t between the work­ing hours

How can we check our time? The sim­plest solu­tion is using the MEDIAN func­tion that returns the val­ue in the mid­dle. Since all our times are in one row, we can just select the range (Fig. 3)

=MEDIAN(B2:D2)

Selecting the whole range
Fig. 3 Select­ing the whole range

If our data is in sep­a­rate cells, we can just add those cells one by one (Fig. 4)

=MEDIAN(B2,C2,D2)

Selecting cells one by one
Fig. 4 Select­ing cells one by one

And just like that we receive the val­ue in the mid­dle. If this val­ue is equal to the giv­en time, it means it’s between the work­ing hours. What’s curi­ous about our medi­an is the fact that it won’t cross our thresh­olds, i.e. our start­ing time and fin­ish­ing time. It means that the small­est val­ue our MEDIAN func­tion can show is the start­ing hour, and the largest is the fin­ish­ing hour (Fig. 5)

The smallest value
Fig. 5 The small­est value

Now, we have to check whether our time is between the work­ing hours. We have to com­pare the func­tion to the giv­en time (Fig. 6)

=MEDIAN(B2,C2,D2)=B2

Comparing
Fig. 6 Comparing 

As we can see, our log­i­cal test returned FALSE (Fig. 7)

FALSE
Fig. 7 FALSE

If the log­i­cal test returns TRUE, it means that the giv­en time is between the work­ing ours (Fig. 8)

TRUE
Fig. 8 TRUE

The answers we have are log­i­cal. Let’s make them more human like by adding the IF func­tion to our MEDIAN log­i­cal test and some sim­ple text like ‘Yes’ and ‘No’ (Fig. 9)

=IF(MEDIAN(B2,C2,D2)=B2,“Yes”,“No”)

Adding the IF function
Fig. 9 Adding the IF function

We can see that we can check whether our giv­en time is between the work­ing ours or no (Fig. 10)

Human answer
Fig. 10 Human answer

https://www.youtube.com/watch?v=IVZIY6-78sc

Median with condition

If you want to cal­cu­late a medi­an val­ue with a con­di­tion, you can­not use a sim­ple MEDIAN func­tion because it needs only num­bers. We have to use anoth­er func­tion that will reduce the num­ber of wages we look at. 

Medi­an with condition

Typ­i­cal­ly, when we want to add a con­di­tion to anoth­er func­tion we can use the IF func­tion and make a log­i­cal test. In our case, the log­i­cal test will be sim­ple. We just have to check each cell in the Depart­ment col­umn whether it’s equal to the name of the Depart­ment we look at now. Since we are com­par­ing a sin­gle cell to a whole range, Excel will check every sin­gle cell in a giv­en range (Fig. 1). 

Comparing a single cell to a range of cells
Fig. 1 Com­par­ing a sin­gle cell to a range of cells

If a cell in the range is equal to the tar­get cell, we want the func­tion to return prop­er wages, i.e. the wages from the same row. If the log­i­cal test result is FALSE, we want to have some­thing that the MEDIAN func­tion will ignore which, in most cas­es, is an emp­ty text string. How­ev­er, I want to show you that the IF func­tion real­ly returns some­thing so let’s write “no” (Fig. 2).

=IF($B$2:$B$13=E2,$C$2:$C$13,“no”)

IF function
Fig. 2 IF function

We can see that Dynam­ic Array Excel spilled the results and we have wages only for the depart­ments we chose. For oth­er depart­ments we have ‘no’. Now, we can put this func­tion into the MEDIAN func­tion (Fig. 3).

=MEDIAN(IF($B$2:$B$13=E2,$C$2:$C$13,“no”))

MEDIAN function with IF function
Fig. 3 MEDIAN func­tion with IF function

Now, we’ve cal­cu­lat­ed the medi­an val­ue with a con­di­tion for each depart­ment. We can see that for HR it’s $4,000, for IT it’s $8,100 and for Mar­ket­ing it’s $5,900. Those are the mid­dle val­ues for each depart­ment (Fig. 4). 

Median values for each department
Fig. 4 Medi­an val­ues for each department

https://www.youtube.com/watch?v=DUYBBhR3wz4

VLOOKUP all matches and combine them

Some­times, we want to find all the matched val­ues and com­bine them into one text string, i.e., we want o VLOOKUP all matched val­ues and then com­bine them.

VLOOKUP all match­es and com­bine them

I will give you two solu­tions. The first solu­tion will work from Excel 2019, and the sec­ond one will work in Dynam­ic Array Excel. First of all, we have to check if our rep­re­sen­ta­tive comes from the coun­try we are look­ing at. Let’s take a rep­re­sen­ta­tive from Spain. There is only one rep­re­sen­ta­tive of Spain in our exam­ple. We can check it using the IF func­tion, where we have to cre­ate a prop­er log­i­cal test. We have to take into con­sid­er­a­tion the Coun­try col­umn, so let’s write it by select­ing the col­umn and click­ing the F4 key to lock it. Then, we have to check if the val­ues from the col­umn are equal to just one coun­try (Spain) by click­ing the cell with the name of Spain (D4). It means that cell D4 will be com­pared to each cell from the Coun­try col­umn indi­vid­u­al­ly (Fig. 1)

Comparison to each cell
Fig. 1 Com­par­i­son to each cell

The log­i­cal test will return TRUE only in the case of Spain. In the case of oth­er coun­tries, it will return FALSE. If the log­i­cal test is in an array, we can choose prop­er, cor­re­spond­ing result as a return val­ue. We just need to select an array of the same size, which, in our case, is the Rep­re­sen­ta­tive col­umn. Then, we click the F4 key to lock it. When the log­i­cal test returns FALSE, we want to see an emp­ty text string, so we have to write a space in dou­ble quotes. Let’s close the func­tion with a paren­the­sis (Fig. 2)

=IF($A$2:$A$14=D2,$B$2:$B$14,” ”)

IF function
Fig. 2 IF function

Since I’m work­ing in Dynam­ic Array Excel, Excel spills the results to the whole col­umn (Fig. 3).

IF function results
Fig. 3 IF func­tion results

We can see that we have only one rep­re­sen­ta­tive of Spain, and many emp­ty cells. If we want to find the remain­ing rep­re­sen­ta­tives, we have to join the infor­ma­tion we have. To do that, we can use the TEXTJOIN func­tion, which is avail­able from Excel 2019. We have to give the func­tion a delim­iter. Let’s write a com­ma and a space in dou­ble quotes. Then, we have to decide whether we want to ignore emp­ty cells. We def­i­nite­ly do, so let’s write TRUE, or its short­er ver­sion, which is 1. Then, we just have to close the whole for­mu­la once again (Fig. 4).

=TEXTJOIN(“, “,1,IF($A$2:$A$14=D2,$B$2:$B$14,” ”))

TEXTJOIN function
Fig. 4 TEXTJOIN function

After enter­ing the for­mu­la and copy­ing it down, we have our results (Fig. 5). 

TEXTJOIN function results
Fig. 5 TEXTJOIN func­tion results

When we are in Dynam­ic Array Excel, we can use the FILTER func­tion instead of the IF func­tion. This func­tion just fil­ters our data. Let’s write FILTER func­tion. Our data is locat­ed only in one col­umn, which is the Rep­re­sen­ta­tive col­umn, so we have write the range and lock it with the F4 key. Then, we have to cre­ate an array of the same size with log­i­cal val­ues of TRUE or FALSE. It means that we have to cre­ate the same log­i­cal test as we did with the IF func­tion. Let’s add the Coun­try col­umn (A2:A14), F4 key to lock it, then an equal sign to check whether any of the val­ue from the Coun­try col­umn is equal to Spain (D2). After clos­ing it, we have a ready for­mu­la (Fig. 6).

=FILTER($B$2:$B$14,A$2:$A$14,=D2)

FILTER function
Fig. 6 FILTER function

We can see that Spain has only one rep­re­sen­ta­tive, but Poland has got three (Fig. 7). 

FILTER function results
Fig. 7 FILTER func­tion results

That’s why we have to put our FILTER func­tion results into the TEXTJOIN func­tion. And, once again, we have to write a com­ma and a space in dou­ble quotes. Then, we have to decide that we want to ignore emp­ty cells and close the whole for­mu­la (Fig. 8)

=TEXTJOIN(“, “,1,FILTER($B$2:$B$14,A$2:$A$14=D2))

TEXTJOIN with FILTER function
Fig. 8 TEXTJOIN with FILTER function

We can see that the results in the first solu­tion and in the sec­ond solu­tion are the same (Fig. 9)

Results
Fig. 9 Results

https://www.youtube.com/watch?v=Nc37zUPDm24