Merge Cells vs Center across selection

How can we cre­ate a head­line title that is in the Cen­ter Across Selec­tion mode?

Merge Cells vs Cen­ter across selection

In Excel, we have two solu­tions. We can select sales and use the Megre&Center com­mand from the Home tab (Fig. 1) 

Megre&Cente command
Fig. 1 Megre&Center command

Excel will merge cells into one cell and align it in the cen­ter (Fig. 2).

One, centered cell
Fig. 2 One, cen­tered cell

This solu­tion, how­ev­er, has got a small draw­back as it cre­at­ed one cell instead of many cells. When we try to select only one col­umn and go a bit too high, we end up in select­ing every col­umn (Fig. 3)

All columns are selected
Fig. 3 All columns are selected

But, when we go down again, we will select only one col­umn again, so it’s not a big prob­lem. Some­times, we want to move our data a bit to the right or left. When we try to copy our range, we can’t select only cell B1, which is a bit prob­lem­at­ic. After select­ing the whole range, we want to move it to the right. How­ev­er, there’s still a prob­lem. If we want to move the range only a bit to the left or right, we can­not do it (Fig. 4).

Merged cells cannot be moved only a bit
Fig. 4 Merged cells can­not be moved only a bit

We have to go far enough to the right to make Excel copy the merged cell (Fig. 5).

 Merged cells moved
Fig. 5 Merged cells moved

I want to show you one more solu­tion. Let’s des­e­lect the Megre&Center com­mand. Now that we have our range select­ed, we can press the Ctrl + 1 short­cut to go to the For­mat Cells win­dow. In the win­dow, we have to go to the Align­ment tab, then select the Cen­ter Across Selec­tion com­mand in the Hor­i­zon­tal area, and press OK (Fig. 6). 

Format Cells window
Fig. 6 For­mat Cells window

We can see that our select­ed cells have merged. But this time, when we try to select one whole col­umn, we can do it (Fig. 7).

Whole column selected
Fig. 7 Whole col­umn selected

You have to remem­ber that now the val­ue is locat­ed in cell A1. There’s noth­ing in B1, C1 and D1 cells. The val­ue was just cen­tered across selec­tion. Let’s now change the col­or­ing of the head­line title and try to move it a bit to the right (Fig. 8).

Moving the range
Fig. 8 Mov­ing the range

As we can see, it’s pos­si­ble (Fig. 9).

The whole range moved a bit
Fig. 9 The whole range moved a bit

When we have the cell in the Cen­ter Across Selec­tion mode, it’s also impor­tant that when we want to add some text to one of the cells, the Cen­ter Across Selec­tion option will work only on the cells that are not filled (Fig. 10)

Center Across Selection working only in cells A1, B1 and C1
Fig. 10 Cen­ter Across Selec­tion work­ing only in cells A1, B1 and C1

https://www.youtube.com/watch?v=9P4HxHSbpbA

Sum of top 3 values

How to cal­cu­late a sum or an aver­age of top 3 max­i­mal values?

Sum of top 3 values

In Lega­cy Excel, we can use the LARGE func­tion, in which we need to select the range for our cal­cu­la­tion. In the k argu­ment let’s write 1 (Fig. 1).

=LARGE($C$2:$C$33,1)

 LARGE function
Fig. 1 LARGE function

After enter­ing the func­tion, we have the largest val­ue (Fig. 2). 

The largest value
Fig. 2 The largest value

Now, we can copy the func­tion and add the sec­ond and the third largest val­ue (Fig. 3).

=LARGE($C$2:$C$33,1)+LARGE($C$2:$C$33,2)+LARGE($C$2:$C$33,3)

Adding more values
Fig. 3 Adding more values

This way we have the sum of 3 largest val­ues (Fig. 4). 

The sum of 3 largest values
Fig. 4 The sum of 3 largest values

This solu­tion, how­ev­er, is the least dynam­ic of all solu­tions we have. We can make this for­mu­la short­er by hard­cod­ing our val­ues. We have to write 1, 2 and 3 as an array (Fig. 5).

=LARGE($C$2:$C$33,{1;2;3})

The first, second and third value written as an array
Fig. 5 The first, sec­ond and third val­ue writ­ten as an array

This way Excel will return three largest val­ues. I’m using Dynam­ic Excel, so the results are spilled (Fig. 6).

Spilled results
Fig. 6 Spilled results

Now, that our val­ues have been hard-cod­ed, we can sum them by using the SUM func­tion. We can also use this func­tion to sum up aver­ages (Fig. 7). 

=SUM(LARGE($C$2:$C$33,{1;2;3}))

Summing up the largest values
Fig. 7 Sum­ming up the largest values

Our results (Fig. 8).

Results
Fig. 8 Results

This solu­tion, how­ev­er, is hard to mod­i­fy, so we can make it a bit more dynam­ic. We can use the ROW func­tion and select the first three rows from the sheet. This way our solu­tion is more dynam­ic (Fig. 9). 

=SUM(LARGE,($C$2:$C$33,ROW(A1:A3)))

A more dynamic solution
Fig. 9 A more dynam­ic solution

Results (Fig. 10). 

Results
Fig. 10 Results

But, in Lega­cy Excel, we should use the SUMPRODUCT func­tion instead of the SUM func­tion or use the Ctrl + Shift + Enter short­cut to put the for­mu­la into the cell (Fig. 11).

=SUMPRODUCT(LARGE,($C$2:$C$33,ROW(A1:A3)))

SUMPRODUCT function
Fig. 11 SUMPRODUCT function

And we have the result. In the sec­ond col­umn, in Dynam­ic Array Excel, we still need the SUM and LARGE func­tions, then the array which is the range we will look at. Then, we can use the SEQUENCE func­tion to cre­ate a sequence of prop­er num­bers, let’s take 3 (Fig. 12).

=SUM(LARGE($C$2:$C$33,SEQUENCE(3)))

Adding the SEQUENCE function
Fig. 12 Adding the SEQUENCE function

We have prop­er results (Fig. 13).

Results
Fig. 13 Results

This solu­tion is much more dynam­ic. Let’s change the num­ber into 5 (Fig. 14).

=SUM(LARGE($C$2:$C$33,SEQUENCE(5)))

3 changed into 5
Fig. 14 3 changed into 5

Here is the result (Fig. 15). 

Results
Fig. 15 Results

In Lega­cy Excel, we can also change one num­ber. Let’s change the num­ber of rows in the range from 3 to 5 (Fig. 16).

=SUMPRODUCT(LARGE($C$2:$C$33,ROW(A1:A5)))

A3 into A5
Fig. 16 A3 into A5

And we have the same result (Fig. 17).

Result
Fig. 17 Result

We have to remem­ber which ver­sion of Excel we have and which solu­tion we can use. 

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

Running Total in Pivot Table

Some­times, you need to cre­ate a run­ning total in piv­ot tables. How to do it properly?

Run­ning Total in Piv­ot Table

Let’s start with cre­at­ing a piv­ot table. Select one cell from our data and go to the Insert tab and select the Piv­ot Table com­mand. A Piv­ot table from table or range win­dow will appear, where we have our range. We need to select the Exist­ing work­sheet radio but­ton and write the loca­tion, which, in our case, will be cell F1. Let’s click the OK but­ton (Fig. 1).

Creating a pivot table
Fig. 1 Cre­at­ing a piv­ot table

And there we have it. In our piv­ot table we need to drag the Date to the Rows labels. 

Dragging the date
Fig. 2 Drag­ging the date

Now, depend­ing on the Excel ver­sion, we have an option of Group by dates. I’m going to group our date by months and years (Fig. 3).

Grouping
Fig. 3 Grouping 

We have our table. Now, I want to add Income so let’s press the Income check­box (Fig. 4). 

 Income checkbox
Fig. 4 Income checkbox

Now, I want to have the income and the run­ning total for the income, so let’s drag the Income two times to the Val­ues area. We can see that we have Sum of Income and Sum of Income 2, where we actu­al­ly want to have our run­ning total (Fig. 5). 

Income and Income 2
Fig. 5 Income and Income 2

Let’s right click any val­ue from Income 2, then select the Show Val­ues as and then the Run­ning Total In option (Fig. 6). 

Selecting the Running Total option
Fig. 6 Select­ing the Run­ning Total option

Now, we have to decide whether we want to base our run­ning total on Date or Years Field. Let’s take Date (Fig. 7).

 Date Field
Fig. 7 Date Field

Now, we can see that in the Income 2 col­umn we have big­ger num­bers. Let’s for­mat them by press­ing any cell in the col­umn and choos­ing the Num­ber For­mat option (Fig. 8). 

Number Format option
Fig. 8 Num­ber For­mat option

In the For­mat Cell win­dow, let’s choose the Cur­ren­cy cat­e­go­ry, in Dec­i­mal places let’s write 0 and press the OK but­ton. Let’s do the same in the Sum of Income col­umn (Fig. 9). 

 Format cell window
Fig. 9 For­mat cell window

Now, we can see that we are work­ing with mon­ey. In each month we have big­ger and big­ger num­bers which means that we have the run­ning total in this col­umn. We can change the name of Sum of Income 2 into Run­ning Total. Since we are using the Date Field as our ref­er­ence point, we have the run­ning total in 2020. In 2021 Excel counts from the start, which means that we have the run­ning total only for 2021. The same is with 2022. If we change the Date field into the Years field in the Show Val­ues as (Run­ning Total) win­dow, we will have the same val­ue in the first year and in the Sum of Income col­umn (Fig. 10).

Years
Fig. 10 Years

How­ev­er, in the next year, we have the the sum from Jan­u­ary 2021 and Jan­u­ary 2020. In Feb­ru­ary, we have the sum from Feb­ru­ary 2021 and 2020. In 2022, we have sums from three Feb­ru­ar­ies (Fig. 11).

Sums from three Ferbuaries
Fig. 11 Sums from three Ferbuaries

Let’s drag Man­ag­er into the columns head­er (Fig. 12).

Dragging Manager into headers
Fig. 12 Drag­ging Man­ag­er into headers

By doing so, we can show val­ue from the Man­ager’s per­spec­tive, which means a hor­i­zon­tal view. 

Horizontal view
Fig. 13 Hor­i­zon­tal view

How­ev­er, this type of data isn’t a prop­er one to show it this way, so let’s get back by press­ing Ctrl + Z two times and see that we can also cre­ate a per­cent run­ning total by going to the % Run­ning Total In option and choose the Date Field (Fig. 14). 

Percentage Running Total
Fig. 14 Per­cent­age Run­ning Total

Now, we can see the val­ues as per­cent­age (Fig. 15). 

Results
Fig. 15 Results

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

Running Total

Some­times you need to cre­ate a run­ning total.

Run­ning Total 

The most ver­sa­tile solu­tion I know is using the SUM func­tion and a dynam­ic range which in our case is $B$2:B2. How­ev­er, the most impor­tant fact is that we have to lock (F4 key) the first part of this range (Fig. 1).

=SUM($B$2:B2)

SUM function
Fig. 1 SUM function

When we copy our for­mu­la down, we can see that the first part of the range will always refer to cell B2, but the sec­ond one will go down as we drag the for­mu­la. This way, we have a range that expands as we go down. It’s the most ver­sa­tile solu­tion (Fig. 2). 

=SUM($B$2:B4)

An expanding range
Fig. 2 An expand­ing range

This solu­tion has prob­lems with Excel tables. When we sum from F2 to F2 cells and press F4 key to lock it, every­thing looks fine. How­ev­er, when we add new data to our table, the last cell will expand because it refers to the whole col­umn July -> August (Fig. 3). 

 Adding a new value
Fig. 3 Adding a new value

In this case, we have to mod­i­fy our range. Instead of cell F2 we can use the table nomen­cla­ture. When we click cell F2, Excel will refer to this table row, where @ means this table row, and Income means the col­umn we are refer­ring to (Fig. 4). 

=SUM($F$2:[@Income])

 Range modification
Fig. 4 Range modification

We have to over­write all cells (Fig. 5). 

Overwriting cells
Fig. 5 Over­writ­ing cells

This way we got prop­er results. We can check if it works prop­er­ly by adding some new rows. After we added two rows, the results are still cor­rect (Fig. 6).

Correct formula operation
Fig. 6 Cor­rect for­mu­la operation

The only draw­back of this for­mu­la is that we won’t see the whole range because Excel won’t select the whole range. The­o­ret­i­cal­ly, the last cell should include the whole col­umn but Excel selects only the first and the last row (Fig. 7).

=SUM($F$2:[@Income])

The formula in the last cell
Fig. 7 The for­mu­la in the last cell

We won’t see it, but Excel will. We have to remem­ber that Excel will cre­ate a prop­er ref­er­ence and we can cre­ate a prop­er run­ning total, even in Excel tables. 

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

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