Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 171

Pivot tables

Pivot tables are easiest to set up when the spreadsheet is designed for data. Field names should be in
row one of the table, with data below. There should be no blank rows within the data.

Pivot tables (known in Microsoft Access as a cross-tab table) groups data by two categories, producing
summary information such as average, sum, or count according to two or more categorizations. As a
part of this process, pivot tables have the ability to take categories in data rows and turn them into field
names. The result feels like a "rotation" of the data, hence the name Pivot table. As an example, the data
on the left below is pivoted to produce the result on the right.

A B C D E F G H
1 State Sex T3 Average of T3 Sex
2 Pohnpei F 80 State F M Grand Total
3 Pohnpei M 65 Chuuk 82.5 67.5 75
4 Pohnpei F 70 Pohnpei 75 70 72.5
5 Pohnpei M 75 Grand Total 78.75 68.75 73.75
6 Chuuk F 95
7 Chuuk M 60
8 Chuuk F 70
9 Chuuk M 75

The result are averages based on state and sex. The data in the Sex column, F and M, has become field
names in a new row one of a table. The data has, in a sense, been "pivoted" or "rotated" up out of a
column and tabulated across as field names in a new table (hence the use of term "cross-tab" by
Microsoft Access).

Graphing Pivot Tables

The data in a pivot table can be graphed to produce charts as was covered in the second session. Be
careful to select only the state and sex breakdown data and not the grand total data. Look carefully at
the diagram below and the note following the diagram.

Making the selection shown must be done by dragging from C20 to A16. Dragging from A16 to C20 is
not possible as A16 is a button that activates when clicked.
Note that in the particular chart shown has been adjusted by rotating the chart 180� from the initial
position. This was done by double-clicking on the chart and then choosing 3-D View from the Format
menu. In the 3-D View dialog box the rotation was set to 200� (initial rotation was 20�).

Pivot tables are best produced by good data designs. In turn, good data designs are produced by
considering the pivot table implications. Good design requires that each data row be a single object or
instance, not a an aggregate of data. Gradebooks almost naturally generate good data designs: a single
student in a single class per row (a "student-seat"). In other applications forethought may be necessary.
In a study of lizards, for example, proper design of a good table is likely to involve listing each
individual lizard in its own row. This would be as opposed to a table where each row was a location and
the data was the number of lizards in that location. The following fictitious table is not well thought out
from a pivot table perspective. For example, although the original tallies might have indicated the
number of females with tails, the resulting table has lost that information. The design is also prone to
typographic errors that result in internally inconsistent data: examine the sum of the number of males
and females on trees.

Number Number Number Num w/


Location
of lizards of Females of Males tail
Beach 2 1 1 0
Pond 6 3 3 5
River 8 5 3 4
Rock 7 5 2 7
Tree 10 6 5 9

A better design would have been:

Location Sex With Tail


Tree F 1
Tree F 1
Tree F 1
Tree F 1
Tree F 1
Tree M 0
Tree M 1
Tree M 1
Tree M 1
Tree M 1
Tree M 1
Pond F 0
Pond F 1
Pond F 1
Pond M 1
Pond M 1
Pond M 1

and so forth. The resulting table can be subtotaled or pivoted to obtain accurate summary information.
Although the original data table will be lengthy, most reports will use the results of subtotal calculations
and pivot tables. The table may have typographic errors, but the totals will at least be consistent with
the data, there will not be any internally conflicting data. Typos will also not likely affect counts the
way they can in the earlier table.

Single-criterion lookup

vlookup function

The vlookup (vertical lookup) function looks up the value in a range by rows (downwards) and then
returns the corresponding information in the same row (rightwards).

Below is an example of how the vlookup function works.

Assume the following dataset about the payrolls of a company:

A B C D

1 Employee_First_Name Employee_Last_Name Base_Salary Bonus

2 Aaron Davis 37000 16000

3 Betty Browns 44000 21000

4 Carl Williams 38000 19000

5 Daisy Johnson 43000 20000

6 Eric Wilson 32000 20000

7 Francis Jones 37000 24000

To look up the base salary of Daisy, the vlookup function looks downwards along the first column until
the text “Daisy” (row 5) is found. It then looks rightwards across the columns to find and return the
value in the “Base_Salary” column.
The vlookup function has the following syntax:

hlookup function

The hlookup (horizontal lookup) function is identical to the vlookup function except that it looks up the
specified value in a range by columns (rightwards) and then returns the corresponding information in
the same column (downwards).

Below is an example of how the hlookup function works.

The dataset is the transpose of the dataset used in the vlookup function.

To look up the base salary of Daisy, the hlookup function looks rightwards along the first row until it
finds the text “Daisy” (column E). It then looks downwards across the rows to find and return the value
in the “Base_Salary” row.

The hlookup function has the following syntax:

Multiple-Criteria Lookup

The above lookups are based on a single lookup key (i.e., a single-criterion lookup). While the vlookup
and hlookup functions do not deal with multiple lookup keys, the different columns (rows) of the
dataset can be joined to create a unique and single lookup key.

Limitations of the vlookup and hlookup function


Below are the limitations of the vlookup and hlookup function:

1) The functions only perform single-direction lookups.

2) The functions return errors when the value is not found.

3) An inserted column (row) distorts the result.

xlookup

If a column named “Employee_ID” is inserted between columns B and C of the dataset, the formula =
vlookup(“Aaron”, A1:D7, 4, FALSE), which originally returned Aaron’s bonus, returns his base salary
because the column index for bonus has changed to 5.

xlookup function [Available in Office 365 or later versions]

The xlookup function enhances both the vlookup and hlookup functions while using a simpler syntax:

Single-criterion lookup

The insertion of a column (row) does not distort the lookup result. If the formula = xlookup(B9, A1:A7,
C1:C7) is originally used to find the base salary of Daisy, inserting a column between columns B and C
does not distort the lookup result because the formula is automatically updated to = xlookup(B9,
A1:A7, D1:D7).

The xlookup function has 4 modes of matching.

The match_mode argument takes the following numbers:

Value Match_Mode

0 Exact match and return an error if not found

-1 Exact match and return the next smaller item if not found
1 Exact match and return the next larger item if not found

2 Approximate match

The xlookup function allows data lookup in the reverse order.

The search_mode argument takes the following numbers:

Value Search_Mode

1 Search starting from the first item

-1 Search starting from the last item

2 Search a sorted list in ascending order

-2 Search a sorted list in descending order

Multiple-criteria lookup

The xlookup function does not require a helper column for multiple-criteria lookups.

In cell B11, the formula = xlookup(B9 & B10, A1:A7 & B1:B7, C1:C7) directly finds the lookup key
“Aaron Williams” from the lookup range and returns the base salary of the employee with the first
name “Aaron” and the last name “Williams.”

Cell Reference

An Excel cell reference, also known as a cell address, is a mechanism that defines a cell on a worksheet
by combining a column letter and a row number. We can refer to any cell (in Excel formulas) in the
worksheet by using the cell references.
For example:

Here we refer to the cell in column A & row 2 by A2 & cell in column A & row 5 by A5. You can
make use of such notations in any of the formulas or copy the value of one cell to another cell (by using
= A2 or = A5).

Types of Cell Reference in Excel

Understanding various cell references primarily makes it easier for us to use Excel formulas and avoid
unexpected formula errors. When copying and pasting Excel formulas, this is quite useful. Based on
various use situations, Excel offers three main types of cell references, including:

 Relative Cell Reference

 Absolute Cell Reference

 Mixed Cell Reference

Relative Cell Reference

In Excel, a relative cell reference is used by default. Excel uses a relative reference whenever we insert
a cell reference or a range within a formula. The relative references, which commonly reflect the
combination of column name and row number, are used normally with the associated cell references.
There is no dollar ($) sign in the relative reference for the cell.
When you need to develop a formula for a set of cells and the formula needs to make a reference to a
relative cell reference, relative cell references come in handy.When this occurs, you can create the
formula in one cell and copy it before pasting it into every other cell.

Absolute Cell Reference

When copying or using AutoFill, there are times when the cell reference must stay the same. A column
and/or row reference is kept constant using dollar signs. So, to get an absolute reference from a relative,
we can use the dollar sign ($) characters.

To refer to an actual fixed location on a worksheet whenever copying is done, we use absolute
reference. The reference here is locked such that rows and columns do not shift when copied.

How to Use Absolute Cell References in Excel

Below is an example depicting how to use Absolute Cell References in Excel.

Example :

When we fix both row & column – Say if we want to lock row 2 & column A, we will use $A$2 as:

G2 = C2/$A$2, when copied to G3, G3 becomes = C3/$A$2


Here, original cell reference A2 is maintained whenever we copy G2 to any of the cells. So I3 =
E3/$A$2 because E3 comes from the relative reference (4 columns left to the current one) & /$A$2
comes from the absolute reference.

Therefore, I3 = E3//$A$2 = 12/10 = 1.2

Dollar ($) Sign

When the row and column numbers are preceded by the dollar symbol ($), it becomes absolute (i.e.,
stops the row and column number from changing when copied to other cells). Dollar ($) before the row
fixes the row & before the column fixes the column.

Use Absolute Cell References in Excel

When you don’t want the cell reference to alter when you replicate formulas, absolute cell references
come in handy. This can be the situation if you have to use a fixed value in the formula.

Mixed Cell Reference

An absolute column and relative row, or an absolute row and relative column, is a mixed cell reference.
You get an absolute column or absolute row when you individually put the $ before the column letter or
before the row number. Example: $B8 is relative to row 8 but absolute for column B, and B$8 is
absolute for row 1 but relative for column A.

Here, the Dollar ($) before the row number fixes/locks the row & before the column name fixes/locks
the column.

Example

When we fix the only row: If we have G2 = C2/A$2 then :

We used $ before the row number, so we are locking the only row here. When G2 is copied to G3, G3 =
C3/A$2 (not C3/A3) because the row has been fixed already.
Here, whenever we copy G2 to any other cell, always the divisor will refer to a fixed row 2 (column
vary according to the concept of relative reference)

So, when G2 is copied to I3, I3 = E3/C$2 because E3 comes from the relative reference (4 columns left
to the current one) & C$2 comes from the absolute reference for row & relative reference for Column
(6 Columns left to the current one)

Relative and Absolute Cell References for Calculating Dates

We can use relative and absolute cell references to calculate dates.

Example: To Calculate the Date of Delivery online from the given date of the order placed & no of
days it will take to deliver :

Here, We calculate the Date of Delivery by = Order Date + No of days to deliver. We used Relative cell
reference so that individual product delivery dates can be calculated.

Absolute cell references for calculating dates :

Example: To Calculate the Date of Birth When the age is known is a number of days using Current
date can be done by making use of absolute reference.
Here, We calculate DOB by = Current Date – Age in days. The Current date is contained in the cell E2
& in subtraction, we fixed that date to subtract from the days.

Whole Column Reference

You will want to refer to all the cells inside a particular column when operating with an Excel
worksheet with any number of rows. Simply type a column letter twice with a colon in between to refer
to the entire column B, for example, B:B.

Example: You may want to find the sum of a column of data in certain cases. While you can do this
with a regular cell range, such as =SUM(B1:B10), you will need to change the cell range if your
spreadsheet grows in size.

Excel, on the other hand, has a cell range that does not require the row number and takes all the cells in
the column in action. If you wanted to find the sum of all the values in column B, for example, you
would type =SUM (B:B). You can add as much data as you want to your spreadsheet without having to
change your cell ranges if you use this type of cell range.
Whole Row Reference

You will want to refer to all the cells inside a particular row when operating with an Excel worksheet
with any number of columns. Simply type a row number twice with a colon in between to refer to the
entire row, for example, 2:2.

Example: You may want to find the sum of a row of data in certain cases. While you can do this with a
regular cell range, such as =SUM(A2 : J2), you will need to change the cell range if your spreadsheet
grows in size.

Excel, on the other hand, has a cell range that does not require the column letter and takes all the cells
in the row in action. If you wanted to find the sum of all the values in row 2, for example, you would
type =SUM (2:2). You can add as much data as you want to your spreadsheet without having to change
your cell ranges if you use this type of cell range.

Refer to an Entire Column, Excluding the First Few Rows

To refer to the entire column excluding the first few rows, you need to specify the range as we give in a
normal fashion. We know that the Excel worksheets can have only 1,048,576 rows. (To check this, go
to an empty cell & press: Ctrl + Down arrow Key)

So, we can do the sum of the entire column B except for the first 5 rows by = SUM(B6:B1048576).
Using a Mixed Entire Column Reference in Excel

You can also create a mixed entire-column reference, say for example $B:B. But, practically, it is
difficult to find a situation where it would be used.

Example :

How to switch between Absolute, Relative, and Mixed References

The $ sign can be manually typed in an Excel formula to adjust a relative cell relation to absolute or
mixed. You can also speed things up by pressing the F4 key. You must be in formula edit mode to use
the F4 shortcut. The steps are :
Firstly, choose the cell that contains the formula. Then, by pressing the F2 key or double-clicking the
cell, you can enter Edit mode. Select the cell reference in which you want to make changes. Then,
switch between four-cell reference forms by pressing F4.

Example: When you select a cell having only relative reference (i.e., no $ sign), say = B2:
 The first time when you press F4, it becomes =$B$2

 The second time when you press F4, it becomes =B$2

 The third time when you press F4, it becomes=$B2

 The fourth time when you press F4, it becomes back to the relative reference=B2

B2 –Press F4–> =$B$2 –Press F4–> =B$2 –Press F4–> = =$B2 –Press F4–> =B2

So, using F4, you do not require to manually type the $ symbol.

Cell Reference to Other Worksheets

Cell reference in Excel are not limited to just the current worksheet. You can also reference cells from
other worksheets within the same workbook. Let’s walk through an example to understand how to
create these references.

Suppose we have two worksheets : “Sheet1” and “Sheet 2”. In “Sheet 2” we have value Student name
that we want reference in “Sheet 1”.

Follow the below steps to create direct reference to “Sheet 2” from “Sheet 1”:

Step 1: Activate a cell in “Sheet 1” where you want to display the referenced value.

Step 2: Type an equal sign(=) in that cell to start a formula or reference.

Step 3: Switch to “Sheet 2” by clicking on its tab at the bottom of the Excel window.

Step 4: Locate the Specific cell that contains the desired value.

Step 5: Click on that cell to include it in the reference.

Step 6: Press Enter to complete the reference.

Once you press Enter, a reference is created in “Sheet 1” that points to the corresponding cell in “Sheet
2”. This means that any changes made to the referenced cell in “Sheet 2” will automatically reflect in
the referenced value within “Sheet 1”.

How to create a named cell in Microsoft Excel


Updated: 03/10/2024 by Computer Hope

To create a named cell in Microsoft Excel, select the cell and click the Name Box next to the formula
bar, as shown in the image. This bar has the current cell location printed in it. For example, if you're in
cell A1, it should currently say A1 in the Name Box. In the Name Box, type the name you want to name
the cell and press Enter.
Once a cell is named, you can refer to this cell in a formula, chart, or anything else that uses cell
references. For example, let's assume you named a cell profits. When creating a new formula, you
could type =sum(B10+profits) to add cell B10 plus the value in the profits cell.

Tip

When naming a cell or range, it can only be one word with no spaces.

Tip

In Excel, use the keyboard shortcut Ctrl+F3 to open the Name Manager. In the Name Manager, you
can create, edit, and delete any Excel names. Once a name is created, you can use the keyboard shortcut
F3 to insert any name.

It is easier to use the name of a cell instead of the cell reference. For example, it's easier to remember
"profits" (as mentioned earlier) instead of the cell containing the profits value

Naming Cells in Excel

A name is a meaningful shorthand that makes it easier to understand the purpose of a cell reference,

constant, formula, or table, each of which may be difficult to comprehend at first glance. For

example, when you are adding up a range of cells that include first quarter sales, such as

(C20:C30), compare how meaningful if you name that range as “firstquartersales” and use in the

formula as follows:

Regular formula to sum up: =SUM(C20:C30)

With the named range: =SUM(firstquartersales)

Syntax Requirements for Naming Source: Microsoft.com

Be aware of the following rules when you create and edit names.

 Valid characters: The first character of a name must be a letter, an underscore character (_),

or a backslash (\). Remaining characters in the name can be letters, numbers, periods, and

underscore characters.

 Cell references disallowed: Names cannot be the same as a cell reference, such as Z$100 or

R1C1.

 Spaces are not valid: Spaces are not allowed as part of a name. Use the underscore character

(_) and period (.) as word separators; for example, Sales_Tax or First.Quarter.

 Name length: A name can contain up to 255 characters.


 Case sensitivity: Names can contain uppercase and lowercase letters. Excel does not

distinguish between uppercase and lowercase characters in names. For example, if you

created the name Sales and then create another name called SALES in the same workbook,

Excel prompts you to choose a unique name.

 NOTE: You cannot use the uppercase and lowercase characters "C", "c", "R", or "r" as a defined

name, because they are all used as a shorthand for selecting a row or column for the currently

selected cell when you enter them in a Name or Go To text box. If your data is formatted as a

Table, Excel automatically names that table by using a generic pattern name such as “Table

1”.

Defining Names

You can define names in three ways:

1. Typing in the Name box in the left of the formula bar: This is

best used for creating a workbook level name for a selected

range.

Copyright © 2020 ASCPL All Rights Reserved Page 2 of 16 MS2016-ExcelPart5 MMS 9/1/2020

Let’s use WeekTwo worksheet in the ExcelPart5.xlsx workbook to practice this concept. Assume you

are trying to figure out how much total spent on Produce and Meat only.

 Select cell ranges F4:F8 (cells for produce).

 Click in the name box and type in “Produce”. After typing, hit Enter button to complete.

 Select cell ranges F13:F15(cells for meat).

 Click in the name box and type in “Meat”, then hit Enter.

 Now you have two cell ranges named Produce, and Meat to use in

formula.

Let’s use these two names in a formula:

 Select an empty cell, cell H2.

 Start typing the =SUM formula “=SUM” followed by the open

parenthesis and the letter “pr” to look for the name “Produce”. The
name “Produce” will show up on from the Formula AutoComplete

drop-down list. Double-click on it to select it. [Alternatively, you can

type in the entire word “Produce”.]

 Type in comma “,” on keyboard to add “Meat” cells into the formula.

Start typing the letter “me” and “Meat” will show up top on the list.

Double-Click to include that in the formula and then type in close parenthesis “)” on keyboard

to end the formula. Then hit Enter.

 Place close parenthesis and hit Enter. You will get the sum result of those cell ranges (F4:F8

and F13:F15) in cell H2. The answer should be 47.31.

2. Select existing row and column labels: You can use the Create from Selection command

(under Formulas tab in Defined Names

group) to conveniently create names

from existing row and column labels by

using a selection of cells in the

worksheet. Let’s use My List worksheet

to practice the following concept.

 On the My List worksheet, select the entire column A or block cell ranges A1:A10, and click

on Create from Selection command. Note: If you use the range of cells, you will have to

extend the cell ranges later if you add more on the named list. By using the entire column

would give you a freedom of adding to or deleting

from your list in later.

 Create Names from Selection box comes up. Accept

to use Top row as the name and click on OK. Now you

have the name “Category”, the same as your column

heading.

 Do the same for the columns with headings: Unit.

Copyright © 2020 ASCPL All Rights Reserved Page 3 of 16 MS2016-ExcelPart5 MMS 9/1/2020
 You should be able to see two names in the drop-down list on the name box. If your

column heading has more than one word, an “underscore” will be

automatically placed between those words.

3. Clicking on the Define Name in the

Defined Names group will bring up New

Name dialog box. This is best used for

when you want more flexibility in

creating names, such as specifying a

local worksheet level scope or creating a

name comment.

 In the same worksheet – My List,

select the cell ranges C1:C19.

 New Name dialog box will

appear.

 The name “Monthly_Expense”

will appear (Note the underscore as names has space in between two words) in the

Name box.

 To specify the scope of the name, in the Scope drop-down list box, select Workbook or

the name of a worksheet in the workbook. (Using the Workbook will allow you to use

this name anywhere in the entire workbook while selecting a particular worksheet will

only allow you to use the name for the chosen worksheet.)

NOTE: By default, names use absolute cell references.

 Click on OK.

Besides, typing the entire name out in the

formula or selecting from the Formula

AutoComplete as shown previously, you can

use Use in Formula command in the


Defined Names group. This command will become active after you create

a name. Click on the drop-down arrow and select a defined name from a

list available to include in your formula.

We are going to use these names in formulas in creating drop-down list in next section.

Editing or Deleting Names

You can use the Name Manager command in the Defined Names group to: create a new name, edit an

existing name or delete a name. Note: if you delete an existing name being used in a formula,

deleting that particular name here will create an error in the cell that contains that formula.

Copyright © 2020 ASCPL All Rights Reserved Page 4 of 16 MS2016-ExcelPart5 MMS 9/1/2020

To delete, select a name by clicking on it. Then Delete.

 To select more than one name in a contiguous group, click and drag the names, or press SHIFT

and click the mouse button for each name in the group.

 To select more than one name in a noncontiguous group, press CTRL and click the mouse

button for each name in the group.

 Click Delete. You can also press the DELETE key. Click OK to confirm the deletion
Conditional Formatting

This command can give you a visual analysis of your raw data to detect critical issues and identify

patterns and trends by applying formatting—such as colors, icons, and data bars—to one or more

cells based on the cell value. To detect the trend correctly over a period of time, it is recommended

to exclude the column or row with total values. To learn this command, open ExcelPart5.xlsx

workbook and use the worksheet ConditionalFormatting.

 We want to learn whether all sales people are meeting their monthly quota of $5000. We will

apply the rule as - “If the value is greater than $5000, color the cell green." By applying this

rule, you'd be able to quickly see which cells contain values over $5000.

 Select the desired cells for the conditional formatting rule. In our example, cells B3:G23.

 From the Home tab, click the Conditional Formatting command. A drop-down menu will

appear.

 Hover the mouse over the desired conditional formatting type, then select the desired rule

from the menu that appears. In our example, we want to highlight cells that are greater than

$5000.

 A dialog box will appear. Enter the desired value(s) into the blank field. In our example, we'll

enter 5000. If you’d like to have a different formatting, click the drop down arrow and change

the style to your choice such as “Red Text” or “Red Border”, etc.

 The conditional formatting will be applied to the selected cells. In our example, it's easy to see

which salespeople reached the $5000 sales goal for each month.

Multiple Conditional Formatting Rules: You can apply multiple conditional formatting rules to a cell

range or worksheet, allowing you to visualize different trends and patterns in your data.

Copyright © 2020 ASCPL All Rights Reserved Page 8 of 16 MS2016-ExcelPart5 MMS 9/1/2020

 For example, if you wanted to see how many cells in that selected data has unusually high data, use

the color data bar to identify the cells. The larger the data, the longer the color bar will be. In our

example, select the Purple Color Bar for the same cells B3:G23.
 The new formatting with color

data bar should apply over the

previous conditional formatting of values more than $5000. See below.

To remove conditional formatting:

 Click the Conditional Formatting command. A drop-down menu will appear.

Copyright © 2020 ASCPL All Rights Reserved Page 9 of 16 MS2016-ExcelPart5 MMS 9/1/2020

 Hover the mouse over Clear Rules, and choose which rules you wish to clear. In our example,

we'll select Clear Rules from Entire Sheet to remove all conditional formatting from the

worksheet.

Using Custom Formatting in Excel

The built-in number formats in Excel are many and useful, but what if the specific format that you want
isn't included in the built-in formats?

For that, you'll have to create your own custom format in Excel. As a general note, you can customize
nearly everything in Excel. You can even create a button with a custom function in Excel.

Creating custom number formats in Excel is not easy right-off the bat, but once you get the hang of the
symbols and what they do, it'll be a breeze. To get started, check out the table below. This table is a
summary of some important symbols in custom formatting.

Symbol Function
# Optional number. If the custom format is #, then the cell will display any number in it.
Decimal point. The decimal points are determined by the number of zeroes you put in after the
.0
period. If the custom format is #.00 and the cell value is 1.5, the cell will display 1.50.
Thousands separator. If the custom format is #,### and the cell value is 5000, the cell will
,
display 5,000.
Displays the character following it. If the custom format is #\M and the cell value is 500, the
\
cell will display 500M.
Text placeholder. If the custom format is @[Red] and the cell value is MUO, the cell will
@
display MUO in red.
Displays custom text. If the custom format is # "Years" and the cell value is 5, the cell will
""
display 5 Years.
Multiplies the number by 100 and shows it as a percentage. If the custom format is #% and the
%
cell value is 0.05, then the cell will display 5%
Creates a condition. If the custom format is [>10]#;; and the cell value is less than 10, the cell
[]
will display blank.

Another important factor to consider when creating a custom format is the order. You can include
different formats for positive numbers, negative numbers, and zero in your custom format by putting a
semicolon (;) between them. Consider the format below:
"Positive"; "Negative"; "Zero"

With this formatting applied, if the cell value is positive, the cell will display the string Positive. For
negative values it will display Negative, and for zero it will display Zero. The custom format doesn't
have to include all three of these conditions. If you put in only the first one, it will be used for all three.

What we talked about here isn't all that there is to custom formatting in Excel, but it's a good starting
point. Now let's turn this knowledge into skill with some examples.

1. Excel Custom Formatting Example: Text Suffixes

To give you an understanding of custom formats in Excel, we're going to start with a simple example.
Let's say that you want to input the duration of some operations into a range of cells.

By creating a custom format that adds an Hours suffix to the cell, you can simply just type in the
numeral value of the years and skip having to type the text. Here's how you can do that:

1. In the Home tab, go to the Number section and click on General.


2. From the menu, select More Number Formats. This will open a new window.
3. In the new window, under Category, select Custom.
4. Select any of the formats.
5. Enter the line below under Type:
6. # "Hours"
7. Press OK.

Now your custom format is ready. Select the cells that you want to apply this custom formatting on,
then repeat the steps above and select the custom format that you just created. Notice how the cell
values are unchanged despite the Hours suffix being displayed in the cells.

The hashtag (#) in the code represents any optional number, but since we didn't include any decimals in
the format, the decimals aren't displayed in the cells. In fact, the numbers are all rounded up.

2. Excel Custom Formatting Example: Decimals and Thousands Separator

It's time we got an example of custom formatting for different values in Excel. As mentioned before,
you can create different formats for positive, negative, and zero values in a single custom cell format.
Let's build on the previous example. Here we have the same spreadsheet, but want to change the
displayed values for negatives and zeros. To improve the accuracy and the readability of the displayed
numbers, we're also going to add a thousands separator and a decimal point.

1. In the Home tab, go to the Number section and click on General.


2. From the menu, select More Number Formats. This will open a new window.
3. In the new window, under Category, select Custom.
4. Select the format you created in the previous section.
5. Enter the line below under Type:
6. ###,###.0 "Hours"; "Value is negative!"; "-"

7. Click OK.
Now if you apply this format to the cells, you'll see that it adds the Hours suffix to the positive values,
displays Value is negative! where the values are negative, and displays—for zeroes. Adding a decimal
point to this custom format inhibited Excel from rounding the numbers, and the thousands separator has
made the numbers easier to read.

Custom formats with text strings allow you to create new things in Excel. For instance, you can use
custom formatting to create a bulleted list in Excel.

3. Excel Custom Formatting Example: Colors and Conditions

Now, let's try something new with custom formatting. In this example, we have the grades of some
students. The grades are out of 20, and if a student has got 10 or above, they have passed the exam. If
not, then they have unfortunately failed.
The goal here is to create a custom format that will display Pass in green if the cell value is 10 or
above, and display Fail in red if the cell value is below 10.

As mentioned before, you can create custom conditions inside brackets ([ ]) and use brackets to specify
font color. Let's get down to it. With that in mind, let's create a custom format with conditions.

1. In the new window, under Category, select Custom.


2. Select any of the formats.
3. Enter the line below under Type:
4. [>=10][Green]"Pass";[<10][Red]"Fail"

5. Click OK.
Once you apply the format to the cells, the cells below 10 will display Fail in red, and the rest will
display Pass in green. Again, note that the cell values haven't changed from the original numbers.

Using custom formatting, you can keep the cell values intact and display text based on the cell values. If
you're interested in using conditions for your custom formats, you should definitely check out
conditional formatting in Excel.

What Is Protecting Excel Sheet?

Protect Sheet in Excel is a feature that locks the workbook using the protect option or using a
password. It ensures that no other user can make changes to our worksheet, especially in a worksheet
shared with multiple users.

The Excel Protect Sheet can be used in various ways where we can allow users to perform some tasks
but not make changes, such as they can select cells to use an AutoFilter but can’t make changes to the
structure, or select from the drop-down instead of adding or deleting data.

For example, to protect an Excel worksheet, we must select the “Review” tab – go to the “Protect”
group – click the “Protect Sheet” option, as shown below.
Then, we can complete the further steps, and protect the sheet. However, protecting using a password is
recommended.

How To Protect A Sheet In Excel

The steps to Protect Sheet in Excel are as follows:

1. First, open the worksheet you wish to save. Then, right-click the worksheet or go to “Review” and “Protect
Sheet.” The option lies in the “Changes” group, then click on “Protect Sheet” from the list of options
displayed.

2. It will prompt you to enter a password.


3. Insert the password as per choice.

4. The section below displays a list of options you can allow the users of the worksheet to perform. Every action
has a checkbox. Check those actions you wish to enable the worksheet users to complete.
5. If no action is checked, the users may only VIEW the file and not perform any updates by default. Click “OK.”

6. Re-enter the password as prompted on the second screen, and click “OK”, as shown.
How To Protect Cells In An Excel Worksheet

The steps to Protect Cells in an Excel Worksheet are as follows:

 Step 1: Right-click on the Excel cell you wish to protect. Then, select “Format Cells” from the menu displayed.

 Step 2: The “Format Cells” window appears. Here, go to the tab named “Protection.”

 Step 3:
o Check “Locked” to lock a particular cell in Excel. It will prevent the cell from editing, and we can only view the
content.
o Check “Hidden” to hide the cell. It will hide the cell, and so the content is invisible.
How To Hide The Formula Associated With A Cell?

The steps to hide the formula associated with a cell are as follows:

 Step 1: As shown below, cell F2 has a formula: D2+E2 = F2.

 Step 2: The “Protection” tab of the “Format Cells” shows that the Excel cell is protected, because both the
“Locked” and “Hidden” options are checked.

 Step 3: As a result, the formula is hidden / not visible in the formula bar, as shown below.
 Step 4: Upon unprotecting the sheet, i.e., when we uncheck the “Locked” and “Hidden” options, the formula
also starts appearing in the formula bar, as shown below.

the different methods to Protect Sheets in Excel

There are three protection categories, as shown in the image below.

• Protect Sheet – It protects a particular worksheet from unwanted changes made by users by limiting
their editing chances. If we want to protect multiple worksheets at a time, it is not possible. However,
we can go to the necessary worksheets, one at a time, and protect sheets.
• Protect Workbook – It protects the entire workbook, i.e., Excel files worksheets. Here, users cannot
make structural changes like adding, moving, or deleting worksheets.
• Allow Edit Ranges – It helps users to edit some cell ranges that are not password protected.

3. How to open the “Format Cells” window to Protect Cells or Hide Formulas?

There are various methods to open the Format Cells window, namely,
• Method 1 – Simply press the shortcut key “Ctrl+1”.
• Method 2 – Select the “Home” tab – go to the “Number” group – click the “Number Format”
option drop-down – select the last option “More Number Formats…”, as shown below.
• Method 3 – Right-click on any cell, and select the “Format Cells…” option from the list, as shown
below.
• Method 4 – Select the “Home” tab – go to the “Number” group – click the “Number Format” box,
i.e., the small box at the bottom right of the “Number” group, as shown below.

Method 1 – Cell Formula Writing + Clicking

First, click the cell in the worksheet you want the data to appear in:

 Type in the formula bar “=”


 Click on the information in the source worksheet you want to carry across
 Press enter

The formula bar will show where the information has been linked to, the sheet name, an
exclamation mark and the cell number:
Note you can link to named ranges as well as cells.

excel-promo-1

Method 2 – Copy And Paste

Start on the source worksheet and copy the information you want to link

 Right click on the cell in the destination sheet and go to ‘Paste special’
 Click on the ‘Data link’ icon. Interestingly, if you are used to opening up the paste special box, the link data
option doesn’t appear in it.
If you use this method, the cell is entered as an absolute cell reference.

You can learn about all types of cell references here.

Linking to Multiple Cells

You can also create a link to multiple sheets and cells to a single cell with a function.

In the example below, the total spend on communications for three years has been shown on the
summary sheet:
To do this, you will use method 1 above but after clicking on the first total in 2010, press ‘+’ then click
the next piece of data and so on.

Create an Advance Chart in Excel

In this example, we will create a column chart and format its various chart elements. We will use
random sales data for different courses for this.

Step 1: Create a Dataset in a workbook

In this step, we will be creating the dataset using the following random sales data for different
courses.
Fig 1 – Dataset

Step 2: Insert Chart

Now, we will be inserting the chart for our dataset. To do this, we need to Select Data and then
navigate to Insert. Then click on Charts and then select Column Chart there.
Fig 2 – Insert Chart

By doing this, Excel will automatically insert a column chart for our dataset.

Fig 3 – Column Chart

The Format Pane is introduced in Excel 2013 which provides a chart formatting option for
various chart elements. To access the formatting pane, we need to Select Chart Element > Right-
Click > Format<chart_element> Excel will open a Format Pane for that particular chart element
on the right side of the spreadsheet.

Step 3: Format Axis

In this step, we will format the chart axis. First, Select Axis, then Right-Click on it, and then select
Format Axis.
Fig 4 – Format Axis

Once we click on the Format Axis option, Excel will automatically open a Format Axis Pane.
Fig 5 – Format Axis

Using the format axis pane, we can format our chart axis according to our requirements. Here, we
are going to change units to display in Hundreds and Tick Mark as Inside for Minor Type.
Fig 6 – Format Axis

Similarly, we will also change the Tick Marks for Minor Type to Inside for Horizontal-Axis and
we will get the following output.
Fig 7 – Formatted Axis Output

Step 4: Format Chart Area

In this step, we will format the Chart Area. To make the chart look more enhanced and cleaner. For
this Select Chart Area and then Right Click on it and select Format Chart Area. Please, make sure
to click on Chart Area, not the Plot Area.

Fig 8 – Chart Area & Plot Area


Once we select the chart area and perform the above operation, excel will open the Format Chart
Area pane.

Fig 9 – Format Char Area Options

To format the chart area pane, we are adding gradient color to our chart. Go to Format Chart Area,
click on Fill & Line, and select Gradient Fill.
Fig 10 – Gradient Fill

Once we choose the Gradient fill option, excel will automatically fill the gradient color to our Chart
Area. Similarly, we will also add the Gradient Fill to our Plot Area, and we will get the following
output.
Fig 11 – Formatted Chart & Plot Area Output

Step 5: Format Chart Title

In this step, we will format the Chart Title.

To make the chart look more enhanced and cleaner. For this Select Chart Title and then Right Click
on it and select Format Chart Title. This will open the Format Chart Title pane on the right side of
the spreadsheet.

Using Format Chart Title, we are choosing the Gradient Fill option to fill gradient color to our chart
title. Also, we will change the title to Sales Chart. After adding these changes, we will get the
following output.
Fig 13 – Formatted Chart Title

Step 6: Format Data Series

In this step, we will format the Chart Data Series. To make the chart look more enhanced and
cleaner. For this Select Chart Data Series and then Right Click on it and select Format Data Series.

Fig 14 – Format Data Series

This will open the Format Data Series pane on the right side of the Excel spreadsheet. Using the
Format Data Series, we will add a 3-D effect to our data series.
Fig 15 – Format Data Series

Once we add the 3-D effect to our data series we will get the following final output.
Fig 16 – Output

FAQs on Chart Formatting


What is the need of formatting a chart?

Formatting the chart makes the chart easier to read and also qualifies you to explain the data in detail.

What are the best-advanced Graphs in Excel?

 Sankey diagram

 Likert Scale chart

 Comparison Bar Chart

 Gauge Chart

 Multi-Axis Line Chart

 Sunburst Chart

 Radar Chart

 Radial Bar Chart

 Box and Whisker Chart

 Dot Plot Chart

How to Create Advanced Charts and Graphs in Excel?


Last Updated : 11 Jan, 2023


Charts, graphics, and images are excellent ways to visualize and convey data, and Excel does the same
for us by generating charts automatically. We might occasionally want to go beyond the basic charts
that Excel generates for us. Let’s learn about advanced charts and graphs used in excel,

Advanced Chart

A more complex chart than Excel’s default one is referred to as an advanced chart. If you want to
compare many sets of data on the same chart, you can start by creating your basic chart with just one set
of data, then add other datasets and other elements, such as formatting. Advanced charts are all about
this. For complicated charts in Excel, they provide aggregated data in a single chart, making it simpler
to evaluate many data sets and take quick decisions. They let us modify how the expert Excel charts
appear and operate.

How to Add Charts and Graphs in Excel

Below are the steps to add charts and graphs in excel:

Step 1: First open the MS-EXCEL and then write your data there in the sheet.
Step 2: Then select all your data. Go to the insert option, from this you can insert any type of chart
and graph according to your data.

Step 3: You will find different charts that are shown below. When hovering over the chart it shows a
brief description and the kind of data it should be used is included in each part.
Charts in excel

Now we are going to discuss all the charts in detail.

Column or Bar Chart

When displaying categorical data, a bar chart or bar graph employs rectangular bars with heights or
lengths proportional to the values they stand for. Vertical or horizontal bar plots are both possible.
Vertical bar graphs are also referred to as column charts. Any type of data column or bar chart can be
used. For example, if we have to show the above-mentioned data in a column chart then.

Step 1: Select all the data. Click on insert a column or bar chart.
insert column or bar chart

Step 2: You will observe the column and bar chart in 2-D and 3-D forms.
Step 3: Here, We are choosing the clustered column for our data representation.
Step 4: Now we can see the clustered column chart with the table.
Bar Chart

Step 1: If we have to show the above-mentioned data in a bar chart for that you need to follow step1
and step2 as same. and then you just have to choose a clustered bar chart this time.
Step 2: Now we can see the clustered bar chart with the table.
Pie or Doughnut Chart

A pie chart is a circular graph that resembles a pie cut into slices (sectors). Slices display the
percentage that each value makes up of the total, with the area of each slice corresponding to the
amount it stands for and the circle signifying 100%. A doughnut chart is a pie diagram with a
blank circle in the center. When comparing categories in tiny data sets, pie charts are frequently
utilized. When there are more than a handful of categories, they shouldn’t be used and cannot be
multiple-series. For example, if we want to show the given below data in a pie chart then:
Step 1: Select all the data. Go to the option insert and then in the chart group select pie or doughnut
chart.
Step 2: You will observe here the pie chart in 2-D and 3-D forms.

Step 3: We are here using the 2-D pie option that is shown below image:
Step 4: Now we can see the pie chart with the table.
pie chart

Doughnut Chart

Step 1: If we have to show the above-mentioned data in a doughnut chart for that you need to follow
step1 and step2 the same and then you just have to choose a doughnut chart option this time.
Step 2: Now we can see the doughnut chart with the table.
Line and Area Chart

Typically, line charts are used to discuss trends over a specific period. The X-axis represents certain
significant measurements, whereas the Y-axis displays numerical values. Since you can see the
specific trend for each data category on a line chart, they are simple to interpret. In practice, finance
managers welcome line types to examine trends in earnings and other aspects of the business. Line
charts and area charts both follow similar patterns. However, a certain hue fills the space between
each line and the X-axis. Area charts are typically the best choice for showing changes between
various data sources. For example, if we want to show the given below data in a line chart then,
Step 1: Select all the data. Go to the option insert line or area chart.
insert line or area chart

Step 2: You will observe the line and area chart in 2-D and 3-D forms.

Step 3: Here, we are using a 2-D normal line chart.


Step 4: Now we can see the line chart with the table.
Area Chart

Step 1: If we have to show the above-mentioned data in an area chart for that you need to follow step 1
and step 2 the same and then you just have to choose an area chart option this time.
Step 2: Now we can see the area chart with the table.
Histogram

A histogram is a diagram that shows how numerical data are distributed. A histogram is a column
chart that more easily conveys the frequency of data within a given range. Utilizing the number of
data points that fall inside a given range of values, allows the visualization of numerical data. For any
type of data, the histogram can be used. For example, if we want to show the given below data in a
histogram then:
Step 1: Select all the data. Go to the option insert statistic chart.
Step 2: You will observe here the histogram and box & whisker.

Step 3: Here we are going to choose a histogram.


Step 4: Now we can see the histogram with the table.
Box and Whisker

A box-and-whisker chart shows quartiles and groups of numerical data from the data collection.
The box depicting the lower and upper quartiles and the lines extending from it gave this
visualization its original name, the boxplot chart (whisker). For example, if we want to show the given
below data in a box and whisker then:
data

Step 1: Select all the data. Go to the option insert statistics chart.
Step 2: You will observe here histograms and box & whisker chart.

Step 3: Here we are going to choose a box and whisker chart.


Step 4: Now we can see the box and whisker chart with the table.
Treemap and Sunburst

These two styles of charts make it simple to identify data patterns or compare data volumes. You can
use a Treemap or sunburst chart in Reports to show the hierarchy by choosing members and
functions from a single dimension. Additionally, you can define element colors and chart
characteristics as necessary. A treemap chart is a type of data visualization that uses stacked
rectangles of various sizes and colors to display hierarchical data. Each level of the hierarchy is
represented by a rectangle, also known as a branch, that contains further rectangles (leaves). Another
tool for representing hierarchical data structures is a sunburst chart. An inner circle and outside
rings of higher hierarchical levels make up a sunburst chart. For example, if we want to show the given
below data in a treemap then:

Step 1: Select all the data. Go to the option insert hierarchy chart.
Step 2: You will observe here treemap and sunburst.

Step 3: Here we are going to choose a treemap.


Step 4: Now we can see the treemap with the table.
Sunburst

For example, if we want to show the given below data in a sunburst then:
data

Step 1: If we have to show the above-mentioned data in a sunburst for that you need to follow step1
and step2 the same and then you just have to choose a sunburst option this time.
Step 2: Now we can see the sunburst with the table.
Map

The newest versions of Microsoft Excel have the Excel Map Chart feature. It enables beautiful and
creative visualization of any kind of geographic data. The Map Chart’s cool feature is the automatic
geographic data identification and recognition, which eliminates the need for you to manually
match your data points with a certain map area. Excel takes care of everything instead, regardless of
whether your data are at the level of a country, state, country, or even postal code. For example, if we
want to show the given below data on a map then:
Step 1: Select all the data. Go to option maps.
Step 2: Here you just need to choose maps.

Step 3: Now we can see the map with the table.


Scatter or Bubble Chart

Both of these charts make it simple to understand the relationship between the two values for all of the
chart’s elements because the X-axis shows one numerical field and the y-axis shows another. The
size of the data points in bubble charts is determined by a third numerical variable. Both bubble
and scatter charts can simultaneously display two or more data dimensions. Data linked to risk
management, audit, and SOX processes are frequently communicated via bubble and scatter charts. For
example, if we want to show the given below data in a scatter(X, Y) chart then:
Step 1: Select all the data. Go to the option insert scatter (X, Y) and bubble chart.
Step 2: You will observe here bubble and scatter charts.

Step 3: Choose a normal scatter chart.


Step 4: Now we can see the scatter chart with the table.
Bubble Chart

Step 1: If we have to show the above-mentioned data in a bubble chart for that you need to follow step
1 and step 2 the same and then you just have to choose a bubble chart option this time.
Step 2: Now we can see the bubble chart with the table.
Waterfall Chart

A waterfall chart sometimes referred to as a flying bricks chart or a Mario chart aids in
understanding the cumulative impact of successively added positive or negative values that may be
time- or category-based. The individual negative and positive modifications are shown as floating
steps, and the initial and end values are displayed as columns. Some waterfall charts join the lines
that separate the columns to give the impression that the chart is a bridge.

For example, if we want to show the given below data in a waterfall chart then:
Step 1: Select all the data. Go to the insert waterfall option that is shown in the below image.
Step 2: You will observe here many charts that are shown below in the image.

Step 3: Here we are going to choose a waterfall chart.


Step 4: Now we can see the waterfall with the table.
Combo Chart

In Excel, a combo chart or combination chart is more frequently used. It combines two or more distinct
Excel charts. For example, if we want to show the given below data in a combo chart then:
Step 1: Select all the data. Go to the Insert combo chart option that is shown in the below image.
Step 2: You will observe here many charts that are shown below in the image.

Step 3: Choose a clustered column-Line chart.


Step 4: Now we can see the clustered column line chart with the table.

Trim and clean

To remove any leading or trailing spaces, or any other unwanted characters, you can use the Trim and
Clean functions. Select the columns you want to clean up, go to the Transform tab > Text Column
group and click Format > Trim or Clean.
Remove duplicate rows

To eliminate duplicate rows in your data, Power Query offers the Remove Duplicates function. Select
the column(s) you want to check for duplicates, then go to the Home tab, and click on Remove Rows >
Remove Duplicates.

Remove duplicates case-insensitive

Please keep in mind that this standard "Remove Duplicates" operation will eliminate only the rows that
are identical in every way, including the letter case. For a case-insensitive deduplication, you need to
modify the M code for the query. Here’s how:

1. Remove case-sensitive duplicates as explained above. Alternatively, you can select and right-click the column
that you want to dedupe, and then choose Remove Duplicates from the context menu.
2. In the Formula Bar, add Comparer.OrdinalIgnoreCase as a comparison criterion to the second argument of the
Table.Distinct function.

In our case, after doing the standard remove duplicates operation, the Table.Distinct function looked
like this:

=Table.Distinct(#"Cleaned Text", {"Full name"})


It successfully removed all the rows with the names in column A that were exactly the same, but it left
some entries with variations in letter case, as shown in the screenshot below:

To fix this issue, you can add the Comparer.OrdinalIgnoreCase criterion to the function like this:

=Table.Distinct(#"Cleaned Text", {"Full name", Comparer.OrdinalIgnoreCase})

This will eliminate all the rows containing duplicates in column A, ignoring the letter case.
Users with advanced Excel skills can do this operation in the Advanced Editor by changing the
Removed Duplicates line to this format:

Table.Distinct(PreviousStep, {"ColumnName", Comparer.OrdinalIgnoreCase})

Note. Sometimes, you may have to look at more than one column to identify duplicate records. For
instance, if a person has different name variations like "Johnson, Bill" and "Johnson, William", you can
also check the Address column for duplicates.

Change data type

In case the imported data doesn't look quite right, you can easily convert it into the correct format.

In our sample dataset, the Registration Date column shows both date and time. To display only the date
part of the values, you need to change the data type of the column from Date/Time to Date. This can be
done in two ways:

 On the Home tab, select Data Type > Date from the ribbon.
 Right-click the column header and choose Change Type > Date.

Custom date format

Power Query applies the default date format from your locale (region settings). To display dates in a
custom format, you can use the DateTime.ToText function. Here are the steps to follow:

1. On the Add Column tab, in the General group, click Custom Column.
2. In the Custom Column dialog window, type a name for the new column in the corresponding box, e.g. "Date in
custom format".
3. In the Custom Column Formula box, enter the DateTime.ToText function with two arguments: the original date
column and the custom format code.
o To add the original date column to the first argument, select it under Available Columns on the right and click
Insert, or double click the column name.
o For the second argument, enter the desired date format such as "dd-MMM-yy" or any other format code.

The complete formula takes this form:

=DateTime.ToText([Registration date], "dd-MMM-yy")

4. Click OK, and a new column with the custom date format will be added to your table.

The formula bar will show the complete formula in the M language, which will look something like
this:
=Table.AddColumn(#"Previous step", "Date in custom format", each
DateTime.ToText([Registration date], "dd-MMM-yy"))

Note.

 The output of this function is a text value, not a datetime value.


 For custom date and time formats, you can use the same format codes as in Excel. The only difference is that in
Power Query, lowercase "m" is for minutes, and uppercase "M" is for months.

By changing the data type, you can format the values in a more suitable way for your analysis.
Similarly, you can change other columns to different data types, such as text, number, or currency,
depending on your needs.

Split column

To split a column into two or more columns by a certain delimiter, you can use the Split Column
function. For example, to split the "Full Name" column into "First Name" and "Last Name", the steps
are:

1. Select the "Full Name" column.


2. Navigate to the Transform tab and, in the Text Column group, click > Split Column > By Delimiter.
3. Pick the delimiter from the dropdown list. If your delimiter is not among the predefined options, choose Custom
and enter the desired character(s) in the box below (comma and a space ", " in this example).
4. Decide at which occurrence of the delimiter to separate the column: left-most, right-most or each delimiter. If a
cell has only one delimiter, any option will do. But if a cell has more than one delimiter, then you have to
choose carefully.
5. When done, click OK.
6. Right-click the header of each new column and choose Rename from the context menu to give them
appropriate names (such as "First Name" and "Last Name").

Tip. If you want to preserve the original column, then duplicate it before splitting. To do this, right-
click the column and choose Duplicate Column from the context menu. This will create a copy of the
column with a (2) suffix in its name. You can then split this column as described above.

Extract values into a new column

If some column in your dataset contains lengthy multi-part strings, you may want to extract certain
information into a new column.

For example, let’s see how to extract the country name from the Address column:

1. Select the column from which you wish to extract values.


2. Navigate to the Add Column tab, click Extract, and choose an appropriate option. In our case, the country
names are separated by a comma, so we choose Text After Delimiter.

3. In the dialog box that pops up, enter the delimiter (a comma and a space ", " in our dataset).
4. Expand the Advanced option section and choose to scan for the delimiter from the end of the input, as the
country name comes after the last comma in a cell. If you need to extract a value from the middle of the string,
indicate how many delimiters to skip.
5. When done, click OK.
A new column with the extracted values will be added to the end of the table, and you can move it to
any position you want by dragging the column header.

Add column from example

When dealing with inconsistent or incomplete data, the standard Split and Extract functions might not
work as expected.

Picture a scenario where country names within the Address column are separated by various delimiters
like commas, spaces, or vertical bars. In such cases, you can rely on Power Query to extract country
names based on an example you provide. This is similar to how Excel's Flash Fill feature works.

Here's how to add a new column using an example from existing columns:

1. Select the column that contains the source data (the Address column in our example).
2. On the Add Column tab, click Column from Examples > From Selection.
3. In the first row of the new column, type the country name that corresponds to the first address. Power Query
will try to infer the pattern and fill the rest of the values based on your example. If some cells are blank or filled
with incorrect values, provide another example in the second row or any other row until Power Query gets it
right.
4. When all the cells are filled with the correct values, press Ctrl + Enter to apply the changes.
You will now have a new column that extracts the country names from the addresses.

Replace missing values

In Power Query, replacing missing values, often represented as null, is a straightforward process:

1. Select the column(s) where you want to handle missing values.


2. On the Home tab, in the Transform group, click Replace Values.
3. In the Replace Values dialog box, fill in two boxes:
o Value To Find: null
o Replace With: enter the replacement value corresponding to your data type (e.g., "0" for numeric columns or
"N/A" for text columns).
4. Click OK, and Power Query will apply the replacement to all the selected columns.
Add conditional column

To add a new column based on a set of conditions that use existing columns, make use of the Add
Conditional Column feature. For example, to add a column that assigns a donor level based on the
donation amount, this is what you need to do:

1. Select any column in your dataset.


2. On the Add Column tab, click on Conditional Column.
3. In the dialog box that opens, type Donor Level as the name of the new column. Then, specify the following
rules:

| If Donation | is greater than or equal to | 4000 | then | Platinum |

| If Donation | is greater than or equal to | 3000 | then | Gold |

| If Donation | is greater than or equal to | 2000 | then | Silver |

| Else | Bronze |

4. Click OK to create the new column.


This feature is similar to writing a nested IF statement in Excel, but it’s a lot easier and more convenient
to use.

By default, the new conditional column will appear at the end of your dataset, and you can drag it to
any position you want.

Replace or remove errors

Power Query makes it easy to fix errors in Excel without spending too much time on debugging
formulas or VBA code. To eliminate errors in your dataset, follow these simple steps.

1. Select the column where you want to handle errors.


2. Right-click the column header.
3. In the context menu, you'll find two key options for handling errors:
o Remove Errors will delete all the rows containing errors within the selected column(s), so be careful with this
option.
o Replace Errors will ask you to specify the replacement value. For numeric columns, it has to be a number, e.g. 0.
For text columns, you can specify any text value, including a blank cell.

Group and aggregate

To summarize or aggregate data by specific groups, Power Query offers the powerful Group By
function.

For example, to calculate the total donation amount by country and donor level, this is what you need to
do:

1. On the Home tab, in the Transform group, click on Group By.


2. In the dialog box that opens, choose Advanced Then, do the following:
o Under Group by, select "Country" and "Donor Level" as the columns to group by.
o Under New column name, type "Total Donation" as the name of the new column.
o Under Operation, choose Sum as the aggregation function.
o Under Column, choose Donation as the column to aggregate.
3. Click OK to apply the changes.
As a result, a new table will be created displaying the grouped and aggregated data. If needed, you can
sort the table by one or more columns: right-click the filter arrow next to the column name and choose
either to sort ascending or descending.

In this example, we get a summary of total donation amounts based on both country and donor level.

Tip. After making the necessary changes in the Power Query Editor, don't forget to load your results
into a worksheet.

That’s how to use Power Query in Excel. Now that you know the basics, go ahead and unlock more
data transforming secrets to impress your boss, colleagues, and clients with your data mastery :-)
What is Power Query?

Power Query is a business intelligence tool available in Excel that allows you to import data from many
different sources and then clean, transform and reshape your data as needed.

It allows you to set up a query once and then reuse it with a simple refresh. It’s also pretty powerful.
Power Query can import and clean millions of rows into the data model for analysis after. The user
interface is intuitive and well laid out so it’s really easy to pick up. It’s an incredibly short learning
curve when compared to other Excel tools like formulas or VBA.

The best part about it, is you don’t need to learn or use any code to do any of it. The power query editor
records all your transformations step by step and converts them into the M code for you, similar to how
the Macro recorder with VBA.

If you want to edit or write your own M code, you certainly can, but you definitely don’t need to.

Get the data used in this post to follow along.

What Can Power Query Do?

Imagine you get a sales report in a text file from your system on a monthly basis that looks like this.

Every month you need to go to the folder where the file is uploaded and open the file and copy the
contents into Excel.

You then use the text to column feature to split out the data into new columns.

The system only outputs the sales person’s ID, so you need to add a new column to the data and use a
VLOOKUP to get the salesperson associated with each ID. Then you need to summarize the sales by
salesperson and calculate the commission to pay out.

You also need to link the product ID to the product category but only the first 4 digits of the product
code relate to the product category. You create another column using the LEFT function to get the first
4 digits of the product code, then use a VLOOKUP on this to get the product category. Now you can
summarize the data by category.
Maybe it only takes an hour a month to do, but it’s pretty mindless work that’s not enjoyable and takes
away from time you can actually spend analyzing the data and producing meaningful insight.

With Power Query, this can all be automated down to a click of the refresh button on a monthly basis.
All you need to do is build the query once and reuse it, saving an hour of work each and every month!

Where is Power Query?

Power Query is available as an add-in to download and install for Excel 2010 and 2013 and will appear
as a new tab in the ribbon labelled Power Query. In 2016 it was renamed to Get & Transform and
appears in the Data tab without the need to install any add-in.

Importing Your Data with Power Query

Importing your data with Power Query is simple. Excel provides many common data connections that
are accessible from the Data tab and can be found from the Get Data command.

 Get data from a single file such as an Excel workbook, Text or CSV file, XML and JSON files. You can also import
multiple files from within a given folder.
 Get data from various databases such as SQL Server, Microsoft Access, Analysis Services, SQL Server Analysis
Server, Oracle, IBM DB2, MySQL, PostgreSQL, Sybase, Teradata and SAP HANA databases.
 Get data from Microsoft Azure
 Get data from online services like Sharepoint, Microsoft Exchange, Dynamics 365, Facebook and Salesforce.
 Get data from other sources like a table or range inside the current workbook, from the web, a Microsoft
Query, Hadoop, OData feed, ODBC and OLEDB.
 We can merge two queries together similar to joining two queries in SQL.
 We can append a query to another query similar to a union of two queries in SQL.

Note: The available data connection options will depend on your version of Excel.

There are a couple of the more common query types available in the top level of the ribbon commands
found in the Get & Transform section of the Data tab. From here we can easily access the From
Text/CSV, From Web and From Table/Range queries. These are just duplicated outside of the Get
Data command for convenience of use, since you’ll likely be using these more frequently.

Depending on which type of data connection you choose, Excel will guide you through the connection
set up and there might be several options to select during the process.

At the end of the setup process, you will come to the data preview window. You can view a preview of
the data here to make sure it’s what you’re expecting. You can then load the data as is by pressing the
Load button, or you can proceed to the query editor to apply any data transformation steps by pressing
the Edit button.

A Simple Example of Importing Data in an Excel File

Let’s take a look at importing some data from an Excel workbook in action. We’re going to import an
Excel file called Office Supply Sales Data.xlsx. It contains sales data on one sheet called Sales Data
and customer data on another sheet called Customer Data. Both sheets of data start in cell A1 and the
first row of the data contains column headers.
Go to the Data tab and select the Get Data command in the Get & Transform Data section. Then go
to From File and choose From Workbook.

This will open a file picker menu where you can navigate to the file you want to import. Select the file
and press the Import button.

After selecting the file you want to import, the data preview Navigator window will open. This will
give you a list of all the objects available to import from the workbook. Check the box to Select
multiple items since we will be importing data from two different sheets. Now we can check both the
Customer Data and Sales Data.
When you click on either of the objects in the workbook, you can see a preview of the data for it on the
right hand side of the navigator window. This is great for a sense check to make sure you’ve got the
correct file.

When you’re satisfied that you’ve got everything you need from the workbook, you can either press the
Edit or Load buttons. The edit button will take you to the query editor where you can transform your
data before loading it. Pressing the load button will load the data into tables in new sheets in the
workbook.

In this simple example, we will bypass the editor and go straight to loading the data into Excel. Press
the small arrow next to the Load button to access the Load To options. This will give you a few more
loading options.

We will choose to load the data into a table in a new sheet, but there are several other options. You can
also load the data directly into a pivot table or pivot chart, or you can avoid loading the data and just
create a connection to the data.

Now the tables are loaded into new sheets in Excel and we also have two queries which can quickly be
refreshed if the data in the original workbook is ever updated.
The Query Editor

After going through the guide to connecting your data and selecting the Edit option, you will be
presented with the query editor. This is where any data transformation steps will be created or edited.
There are 6 main area in the editor to become familiar with.

1. The Ribbon – The user interface for the editor is quite similar to Excel and uses a visual ribbon style command
center. It organizes data transformation commands and other power query options into 5 main tabs.
2. Query List – This area lists all the queries in the current workbook. You can navigate to any query from this area
to begin editing it.
3. Data Preview – This area is where you will see a preview of the data with all the transformation steps currently
applied. You can also access a lot of the transformation commands here either from the filter icons in the
column headings or with a right click on the column heading.
4. Formula Bar – This is where you can see and edit the M code of the current transformation step. Each
transformation you make on your data is recorded and appears as a step in the applied steps area.
5. Properties – This is where you can name your query. When you close and load the query to an Excel table,
power query will create a table with the same name as its source query if the table name isn’t already taken.
The query name is also how the M code will reference this query if we need to query it in another query.
6. Applied Steps – This area is a chronological list of all the transformation steps that have been applied to the
data. You can move through the steps here and view the changes in the data preview area. You can also delete,
modify or reorder any steps in the query here.

The Query List

The Query List has other abilities other than just listing out all the current workbook’s queries.
One of the primary functions of the query list is navigation. There’s no need to exit the query editor to
switch which query you’re working on. You can left click on any query to switch. The query you’re
currently on will be highlighted in a light green colour.

When you do eventually exit the editor with the close and load button, changes in all the queries you
edited will be saved.

You can hide the query list to create more room for the data preview. Left click on the small arrow in
the upper right corner to toggle the list between hidden and visible.

If you right click on any query in the list, there are a variety of options available.

 Copy and Paste – Copy and paste a query to make another copy of it.
 Delete – Delete the query. If you accidentally delete a query, there’s no undo button, but you can exit the query
editor without saving via close and load to restore your query.
 Rename – Rename your query. This is the same as renaming it from the properties section on the left hand side
of the editor.
 Duplicate – Make another copy of the query. This is the same as copy and paste but turns the process into one
step.
 Move To Group – Place your queries into a folder like structure to keep them organised when the list gets large.
 Move Up and Move Down – Rearrange the order your queries appear in the list or within the folder groups to
add to your organisational efforts. This can also be done by dragging and dropping the query to a new location.
 Create Function – Turn your query into a query function. They allow you to pass a parameter to the query and
return results based on the parameter passed.
 Convert To Parameter – Allows you to convert parameters to queries or queries to parameters.
 Advanced Editor – Open the advanced editor to edit the M code for the query.
 Properties – Allows you to change the query name, add a description text and enable Fast Data Load option for
the query.

If you right click any empty area in the query list, you can create a new query.

The Data Preview

The main job of the data preview area is to apply transformation steps to your data and show a preview
of these steps you’re applying.

In the data preview area, you can select columns with a few different methods. A column will be
highlighted in a light green colour when it’s selected.
 Select a single column with a left click on the column heading.
 Select multiple adjacent columns with a left click on the first column heading, then hold Shift and left click on
the last column heading.
 Select multiple non-adjacent columns by holding Ctrl then left click on any column headings you want to select.

You can then apply any relevant data transformation steps on selected columns from the ribbon or
certain steps can be accessed with a right click on the column heading. Commands that are not
available to your selected column or columns will appear grayed out in the ribbon.

Each column has a data type icon on the left hand of the column heading. You can left click on it to
change the data type of the column.

You can choose from decimal numbers, currency, whole numbers, percentages, date and time, dates,
times, timezone, duration, text, Boolean, and binary.

Using the Locale option allows you to set the data type format using the convention from different
locations. For example, if you wanted to display the date in the American m/d/yyyy format instead of
the usual dd/mm/yyyy then you could select United States as the locale.
There’s a small table icon in the top left hand corner of the data preview, you can right click or left
click this to access various actions that affect the whole table.

Renaming any column heading is really easy. Double left click on any column heading then type your
new name and press Enter when you’re done.
You can change around the order of any of the columns with a left click and drag action. The green
border between two columns will become the new location of the dragged column when you release the
left click.

Each column also has a filter toggle on right hand side. Left click on this to sort and filter your data.
This filter menu is very similar to the filters found in a regular spreadsheet and will work the same way.

The list of items shown is based on a sample of the data so may not contain all available items in the
data. You can load more by clicking on the Load more text in blue.
Many transformations found in the ribbon menu are also accessible from the data preview area using a
right click on the column heading. Some of the action you select from this right click menu will replace
the current column. If you want to create a new column based, use a command from the Add Column
tab instead.

The Applied Steps

Any transformation you make to your data will appear as a step in the Applied Steps area. It also
allows you to navigate through your query. Left click on any step and the data preview will update to
show all transformations up to and including that step.

You can insert new steps into the query at any point by selecting the previous step and then creating the
transformation in the data preview. Power Query will then ask if you want to insert this new step.
Careful though, as this may break the following steps that refer to something you changed.
You can delete any steps that were applied using the X on the left hand side of the step name in the
Applied Steps area. Caution is needed though, as if any of the following steps depend on the step
you’re trying delete, you will break your query. This is where Delete Until End from the right click
menu can be handy.

A lot of transformation steps available in power query will have various user input parameters and other
setting associated with them. If you apply a filter on the product column to show all items not starting
with Pen, you might later decide you need to change this filter step to show all items not equal to Pen.
You can make these edits from the Applied Step area.

Some of the steps will have a small gear icon on the right hand side. This allows you to edit the inputs
and settings of that step.

You can rearrange the order the steps are performed in your query. Just left click on any step and drag
it to a new location. A green line between steps will indicate the new location. This is another one
you’ll need to be careful with as a lot of steps will depend on previous steps, and changing ordering can
create errors because of this.
Right click on any step to access a menu of options.

 Edit Settings – This allows you to edit the settings of the step similar to using the gear icon on the right hand
side of the step.
 Rename – This allows you to rename the steps label. Instead of the displaying the generic name like “Filtered
Rows“, you could have this display something like “Filtered Product Rows on Pens” so you can easily identify
what the step is doing.
 Delete – This deletes the current step similar to the X on the left hand side of the step.
 Delete Until End – This allows you to delete the current step plus all steps up until the end. Since steps can
depend on previous steps, deleting all steps after a step is a good way to avoid any errors.
 Insert Step After – This allows you to insert a new step after the current step.
 Move Up and Move Down – This allows you to rearrange the query steps similar to the dragging and dropping
method.
 Extract Previous – This can be a really useful option. It allows you to create a new copy of the query up to the
selected step.

The Formula Bar

When you click on different steps of the transformation process in the Applied Steps area, the formula
bar updates to show the M code that was created for that step. If the M code generated is longer than the
formula bar, you can expand the formula bar using the arrow toggle on the right hand side.
You can edit the M code for a step directly from the formula bar without the need to open the advanced
editor. In this example, we’ve changed our filter from “Pen” to “Chair” by typing in the formula bar
and then pressing Enter or using the check mark on the left to confirm the change. Press Esc or use the
X on the
left to discard any changes.

The File Tab

The File tab contains various options for saving any changes made to your queries as well as power
query options and settings.

 Close & Load – This will save your queries and load your current query into an Excel table in the workbook.
 Close & Load To – This will open the Import Data menu with various data loading options to choose from.
 Discard & Close – This will discard any changes you made to the queries during your session in the editor and
close the editor.

Note, you will still need to save the workbook in the regular way to keep any changes to queries if you
close the workbook.

Close & Load and Close & Load To commands are also available from the Home tab.
Data Loading Options

When you use the Close & Load To option to exit the editor, this will open the Import Data menu.

You can choose to load the query to a table, pivot table, pivot chart or only create a connection for
the query. The connection only option will mean there is no data output to the workbook, but you can
still use this query in other queries. This is a good option if the query is an intermediate step in a data
transformation process.

You’ll also be able to select the location to load to in your workbook if you selected either a table, pivot
table or pivot chart in the previous section. You can choose a cell in an existing worksheet or load it to a
new sheet that Excel will create for you automatically.

The other option you get is the Add this data to the Data Model. This will allow you to use the data
output in Power Pivot and use other Data Model functionality like building relationships between
tables. The Data Model Excel’s new efficient way of storing and using large amounts of data.

The Queries & Connections Window

When you’re working outside of the power query editor, you can see and interact with all the queries in
the workbook through the Queries & Connections window. To open this, go to the Data tab in the
regular Excel ribbon, then press the Queries & Connections command button found in the Queries &
Connections section.

When opened it will be docked to the right hand side of the workbook. You can undock it by left
clicking on the title and dragging it. You can drag it to the left hand side and dock it there or leave it
floating. You can also resize the window by left clicking and dragging the edges.
This is very similar to the query list in the editor and you can perform a lot of the same actions with a
right click on any query.

One option worth noting that’s not in the query list right click menu, is the Load To option. This will
allow you to change the loading option for any query, so you can change any Connection only queries
to load to an Excel table in the workbook.
Another thing worth noting is when you hover over a query with the mouse cursor, Excel will
generate a Peek Data Preview. This will show you some basic information about the query.

 Data Preview – This is a live preview of the data similar to when first setting up a query.
 Columns – This will give you a list of all the columns contained in the final results of the query along with a
count of how many columns there are. Clicking on any of them will highlight the column in the data preview.
 Last Refreshed – This will tell you when the data was last refreshed.
 Load Status – This displays whether the data is loaded to a table, pivot table, pivot chart or is a connection only.
 Data Sources – This will show you the source of the data along with a count of the number of files if you’re it’s a
from folder query.
 View in Worksheet – Clicking on this will take you to the output table if the query is loaded to a table, pivot
table or pivot chart.

You can also access this Peek view by right clicking on the query and selecting Show the peek.
There are also some useful messages displayed in the Queries & Connections window for each query. It
will show you if the query is a connection only, if there were any errors when the query last ran, or how
many rows loaded.

The Home Tab

The Home tab contains all the actions, transformations, and settings that will affect the whole table.

1. Close – You can access the Close & Load and Close & Load To options from here. These are also available in the
File tab menu.
2. Query – You can refresh the data preview for the current query or all query connections. You can also open the
properties settings and the advanced editor for the current query and there are options under the Manage
button to delete, duplicate or reference the current query.
3. Manage Columns – You can navigate to specific columns and choose to keep or remove columns.
4. Reduce Rows – You can manage the rows of data from this section. There are lots of options to either keep
certain rows or remove certain rows. Keep or remove the top N rows, the bottom N rows, a particular range of
rows, alternating rows, duplicate rows or rows with errors. One option only available for removing rows is to
remove blank rows.
5. Sort – You can sort any column in either ascending or descending order.
6. Transform – This section contains a mix of useful transformation options.
o Split Columns – This allows you to split the data in a column based on a delimiter or character length.
o Group By – This allows you to group and summarize your data similar to a Group By in SQL.
o Data Type – This allows you to change the data type of any column.
o Use First Row as Headers – This allows you to promote the first row of data to column headings or demote the
column headings to a row of data.
o Replace Values – This allows you to find and replace any value from a column.
7. Combine – This sections contains all the commands for joining your query to with other queries. You can
merge, append queries or combine files when working with a from folder query.
8. Parameters – Power Query allows you to create parameters for your queries. For example when setting up a
from folder query, you may want the folder path to be a parameter as so you can easily change the location.
You can create and manage existing parameters from this section.
9. Data Sources – This section contains the data source settings including permissions management for any data
sources that require passwords to access.
10. New Query – You can create new queries from new data sources or previously used data sources from this
section.

The Difference Between the Transform and Add Column Tabs

The bulk of all transformations available in power query can be accessed through either the Transform
tab or the Add Column tab.
You might think there is a lot of duplication between these two tabs. For example, both tabs contain a
From Text section with a lot of the same commands. It’s not really the case, there is a subtle
difference!

When you use a command from the Add Column tab that is found in both tabs, it will create a new
column with the transformed data and the original column will stay intact. Whereas using the equivalent
command from the Transform tab will change the original column and no new column is created.

This is a critical point to be aware of!

The Transform Tab

The Transform tab sections.

1. Table – This section contains commands that will transform the entire table. You can group and aggregate your
query, promote rows to headers, demote headers to rows, transpose your data, reverse row order, and count
rows.
2. Any Column – This section contains commands that will work on any column of data regardless of data type.
You can change the data type, automatically detect and change the data type, rename the column heading, find
and replace values, fill values down (or up) a column to replace any blanks or nulls with the value above it (or
below it), pivot or unpivot columns, move columns to a new location or convert a column to a list.
3. Text Column – This section contains commands for text data. You can split columns with a delimiter, format the
case, trim and clean, merge two or more columns together, extract text, and parse XML or JSON objects.
4. Number Column – This section contains commands for numerical data. You can perform various aggregations
like sums and averages, perform standard algebra operations or trigonometry and round numbers up or down.
5. Date & Time Column – This section contains commands for date and time data. You can extract information
from your dates, times and duration data.
6. Structured Column – This section contains commands for working with nested data structures such as when
your column contains tables.

The Add Column Tab

The Add Column tab contains a lot of commands similar to the Transform tab, but the key difference
is they will create a new column with the transformation.
1. General – This section allows you to add new columns based on formulas or custom functions. You can also add
index colummns or duplicate a column from here.
2. From Text – Very similar to the From Text section in the Transform tab, but these commands will create a new
column with the transformation.
3. From Number – Very similar to the From Number section in the Transform tab, but these commands will create
a new column with the transformation.
4. From Date & Time – Very similar to the From Date & Time section in the Transform tab, but these commands
will create a new column with the transformation.

The View Tab

The View tab is quite sparse in comparison to the other tabs. There are no transformation commands to
be found in it. Most Power Query users will rarely need to use this area, but there are still a few things
worth knowing about.

1. Layout – This section allows you to either show or hide the Query Setting pane (which contain the properties
and applied steps) and the Formula Bar.
2. Data Preview – This section allows you to show or hide whitespace characters or turn the font into a
monospace font in the data preview area. This is handy when dealing with data delimited by a certain number
of characters.
3. Columns – This allows you to go to and select a certain column in the data preview. This command is also
available in the Home tab.
4. Parameters – This allows you to enable parameterization in data sources and transformation steps.
5. Advanced – This will open the advanced query editor which shows the M code for the query. This is also
available from the Home tab.
6. Dependencies – This will open a diagram view of the query dependencies in the workbook.

In particular, the Query Dependencies view is a useful resource that allows you to see a visual
representation of the data transformation process flow.

What is Power Query?

Power Query is a tool used to manipulate data and is commonly used to transform data for business
intelligence projects.

High quality analysis relies on well-organized data that is free from errors and that draws data from a
single source of truth. While many analysts spend hours of time manipulating data, combining data and
performing lookups, Power Query allows all of these steps to be automated with simple, repeatable
steps.

Power Query is one of the most transformative tools available to any analyst working with data in
Excel. Not only will it save analysts hours of time, but it will result in reduced manual errors, and a
better ability to source data from a single source of truth.
Video Player

00:00

01:00

Key Highlights

 Power Query is a data transformation tool available in both Microsoft Excel and Power BI.
 Power Query is an invaluable tool for any analyst working in Excel, saving users hours of time,
reducing manual errors, and allowing users to source data from a central source of truth.
 Power Query remembers the user’s data transformation steps, effectively automating lengthy and
manual processes.
 Common use cases are to modify the layout of data, connected to central data sources, merge related
tables, or combine multiple files.

Top Uses/Benefits of Power Query


1. Transforming Data

The core purpose of Power Query is to transform data. This means modifying the layout, removing
errors, and generally making the data more usable for analysis.

Common data transformations performed in Power Query include:

 Pivot / Unpivot
 Splitting / Merging Columns
 Filtering Data
 Creating custom columns
 Deleting header / blank / error rows
 Changing data types
 Fill down values

Example: In this example, a user wants to calculate the monthly performance of each store. The
problem is that the data in their text file looks like this (below).

This type of data will be very familiar to Excel users, who know just how much work is involved in re-
formatting data to fit their analysis needs.

There are unneeded rows at the top of the file, columns of blank values, values to fill down and dates to
unpivot.
With a few simple steps Power Query gives the user the ability to transform the data into the below
format. And importantly, the process probably took about a minute to complete.
2. Repeatable Steps

If the above example isn’t enough, Power Query also remembers each of the steps that were taken to
transform the data. This means that when reports are refreshed or changes are made, model inputs can
be refreshed in seconds, with no need to re-do the whole process from scratch.

Example: In this image, we can see the list of steps that have been applied to the dataset. Each time we
update the data source, the steps are applied, and the outputs are updated.

3. Combining Multiple Tables

Power Query allows us to combine multiple tables of related data. Excel users would achieve the same
task using lookup formulas. They’d be limited to 1 million rows and find their models became
increasingly slow with the addition of so many formulas.

Instead, Power Query joins the tables efficiently using matching columns, does not require any
formulas, and is achieved for the entire dataset in seconds.

Example: In this example, we have a table of transactions on the left. In the right table, we have some
supporting information about the delivery of each transaction.
With just a couple of clicks in Power Query, we can use the matching columns to merge the two tables
and add the delivery information to the original table.

4. Combining Multiple Files

Power Query includes functionality to seamlessly combine data from multiple similar files.

Example: Suppose we have three similar files, each containing sales data for our stores in a given
month. Our model requires a single file with a consolidated list of transactions.
With Power Query, we can easily combine the above files into a single table, as shown below. This can
save analysts huge amounts of time and manual error risk.

5. Connection to Central Data Sources

Power Query includes many connectors which allow you to pull data from SQL databases, web pages,
cloud storage, and local files. By always referencing central sources of data, analysts can ensure they
are all working from the one version of the truth.

Using the Get Data menu, it’s easy to customize queries to source data from each data source type.

For a full list of Power Query connectors available, please refer to the Microsoft Power Query
Connectors documentation.

Components of the Power Query Editor

The Power Query editor has the following sections to help you navigate it easily:
 The Ribbon: Much like Excel, the ribbon helps us get around and complete all our basic tasks at the click
of a button.
 The Data View: This makes up much of the screen and is our primary way to interrogate the data that
we’ve imported.
 Applied Steps & Properties: This is where we can see what transformations have been applied to our
dataset and give our query a name.
 Formula Bar: While Power Query allows us to use a graphical interface to click our way through
transformations, it’s secretly converting that into a language called M-code. The formula bar helps us
see exactly what is being done and allows us to modify each step if necessary.
 Query Pane: If we’re working with more than one query or table, the query pane can help us navigate
between them.

Video Player

00:00

02:38

Who Should Use Power Query?


1. Analysts working in Excel

Anybody working in Excel will drastically improve their ability to work with and manipulate data using
Power Query. Instead of manually updating models every week or month, analysts can now automate
inputs and focus on their work.

2. Analysts interested in business intelligence

Transforming data for projects is an essential step in the business intelligence process (see below). For
that reason, Power Query is a great place to start for any Excel-based analyst interested in Business
Intelligence. It makes use of the familiar Excel environment, provides transferable skills into Power BI,
and is incredibly easy to use.

The Business Intelligence Process

3. Anyone working with data

Even if Excel or Power BI are not your primary BI tools, Power Query is perfect for playing around
with data or quickly combining files for other projects. Load the outputs into a worksheet and use it to
quickly prototype a BI project with clean data.

How Does Power Query Work?

Power Query effectively works in three stages:

 First, we connect to the desired data sources, usually with minimal code, and import that data into the
Power Query environment.
 Next, we apply the transformations we want, to filter, combine, sort, group, and merge our data.
 Finally, we choose where we want that data to go. We can load it into a Power Pivot data model, load it
into an Excel sheet, or simply use it as a reference table for another query.
Where Can I Find Power Query?

Power Query is available in both Microsoft Excel and Microsoft Power BI.

Power Query in Excel

Since Excel 2016, Power Query has been available natively. If you have an earlier version of Excel, you
may have to download it as an add-in.

In recent versions, Power Query can be accessed via the Data tab in Excel and consists of several
buttons in the Get & Transform Data section.

Power Query in Power BI

Power BI is Microsoft’s market-leading dashboarding tool, which allows users to import and transform
data, create a data model, and create interactive dashboards.

Power BI makes use of the same Power Query technology to perform all the required data
transformations. It can be accessed via the Data and Queries sections of the Home tab.

Power Query in Excel

Power Query is an excel tool used to import data from different sources, transform (change) it as
required, and return a refined dataset in the workbook. Every change made to the data is recorded and
saved as a step. In future, whenever the data source is updated, the same changes are performed
automatically with the click of the “refresh” button.

For example, an organization has 180 files containing the purchases made in the last 15 years. To
consolidate and analyze these numbers, either of the following steps can be performed:
 Open the different files and copy-paste the entire data in one worksheet. Apply the various functions of
Excel to convert the data into meaningful reports.
 Use Power Query to import data from the different files. Set up a query which consists of making step-
by-step changes to the data. Load the transformed data in a worksheet to create reports.

If the organization follows the pointer “a,” it will have to perform a lot of manual work. These tasks are
often tedious and repetitive. However, if pointer “b” is followed, the transformations are performed
automatically every time data is updated. This saves a lot of time and speeds up the process of
consolidating excel data.

Power Query in excel performs the extract, transform, and load operations (ETL) on a dataset. All
transformations (steps or changes) applied to the data are collectively known as a query. By performing
these transformations, the data is said to be shaped.

The major advantage of Power Query in excel is that it is a fast and efficient way of working on large
datasets. Besides, it is reusable as the same query can be used again on a new dataset. Moreover, with
just a few clicks, one can have access to cleansed and sorted data.

Power Query can be installed as an add-in in Excel 2010 and 2013. In Excel 2016 and the subsequent
versions, Power Query is a built-in excel feature. It can be accessed from the “get data” drop-down (in
the “get and transform data” group) of the Data tab of Excel.

Using Power Query in Excel

To use Power Query in Excel, the following steps need to be performed:

1. Import data: Import data from the different sources. The data source can be a text file, Excel workbook,
web, pdf, and so on. With Power Query, one can work with data from any source having any size and
shape.
2. Transform data: Change, sort and shape data as per the requirements. For instance, one can delete or
insert a row and/or column, replace a missing value, delete a duplicate entry, filter a column, and so on.
These changes are recorded as a query in the sequence in which they are applied to the data.
3. Consolidate data: Consolidate or combine the data from the different sources. Once integrated, a
consolidated database can be generated. The merging and appending of queries are carried out at this
stage.
4. Load data: Load the data on a worksheet once it has been transformed and consolidated. Loading the
data helps return an output in the workbook. The output can be in the form of a table, pivot chart or a
pivot table. Prior to loading, one can preview the data to ensure it is on the right track.
You are free to use this image on your website, templates, etc, Please provide us with an attribution link

Example of Power Query in Excel

The following image shows two Excel files (“data” and “salesdat”) and two text files (“year 2015 data”
and “year 2016 data”). We want to perform the following tasks:

 Import all these files (Excel and text files) to the Power Query editor.
 Combine the data of the two text files. Extract this data as a single table and load it to an Excel
worksheet.

The steps to perform the given tasks are listed as follows:

Step 1: To import data, click the drop-down of “get data” (in the “get and transform data” group) from
the Data tab of Excel.

Open the options of “from file.” Select “from folder,” as shown in the following image.
Step 2: Click “browse” and look for the folder containing the text files (shown in the first image of this
example). Select the correct path of the folder and click “Ok.”

Step 3: A dialog box opens containing the list of files in the selected folder. The same is shown in the
following image.

The column headers of this box are “content,” “name,” “extension,” “date accessed,” “date modified,”
“date created,” “attributes,” and “folder path.”

At the bottom of this box, the following options are displayed:

1. Combine: This combines all the files of the folder. In other words, the user is not given an option to
select the files to be combined. The combine drop-down shows the following options:
o Combine and transform data–This helps consolidate all files with a query. Then, it opens the
“power query editor” window.
o Combine and load–This helps create a query and load the data to the worksheet.
o Combine and load to–This opens the “import data” window after a query has been created.
2. Load: This displays the following options:
o Load–This loads the data as tables in the worksheet.
o Load to–This opens the “import data” window, which shows more loading options.
3. Transform data: This helps create a query and open the “power query editor.” Moreover, it allows
choosing the files to be combined. So, one can combine the files having the same extension.

Since only the text files (with extension “.txt”) are to be combined, click “transform data.”

Note: Use “combine” when the folder contains only those files that are to be combined. Use “transform
data” when the files to be combined are to be chosen after filtering.

Step 4: The “power query editor” window opens, as shown in the following image. The Excel and text
files have been imported to this window.

On the right side, the “query settings” pane is displayed, which consists of “properties” and “applied
steps.” Connection with the source folder is the only applied step at present.

Further, there are three columns named “content,” “name,” and “extension” on the left side. The
extensions are shown (in the column “extension”) in both lowercase and uppercase.
Step 5: Convert all the entries of the column “extension” to lowercase. This is being done because we
need to filter the text extensions in the subsequent step (step 6).

For changing the case, select the column “extension” and click the “format” drop-down. Select
“lowercase,” as shown in the following image.

Step 6: Once all the entries of the column “extension” are displayed in lowercase, apply the filters. For
this, click the drop-down arrow of the column “extension.” The options of this menu are displayed in
the following image.

Since the data of only the text files are to be extracted, select the checkbox of “.txt” and click “Ok.”
Step 7: To combine the data of the two text files, click the icon displaying near the header “content.”
The same is shown within a red box in the following image.

Note: Prior to combining files, ensure that they all have the same extension and structure.

Step 8: A dialog box captioned “combine files” opens, as shown in the following image. Select “tab” as
the “delimiter.” This is because a tab separates the entries of the text files.

In “data type detection,” select “based on first 200 rows.” This implies that the data type detection
needs to be done on the first 200 rows of the dataset.

One can preview the data of the combined text files on the left side of the “combine files” window. If
the preview is fine, click “Ok.”

Note: By default, the first file of the list is used as the sample file. However, one can select a different
file as the sample file. For this, use the drop-down menu under “sample file”.
Step 9: The “power query editor” window opens. It shows the data of the combined text files as a single
table.

Step 10: Add transformations to the extracted dataset. Change the data type of the “revenue” column to
“currency.” For this, click the drop-down near the header “revenue” and select “currency.”

The same is shown in the following image.


Step 11: The number of applied steps has increased, as shown in the following image.

Note: One can click on any of the “applied steps” to see how data appeared after applying the specific
step.

Step 12: Once the transformations to the data are complete, load the combined dataset to an Excel
worksheet. For this, click the drop-down of “close and load” (in the “close” group) from the Home tab
of the “power query editor” window.

Select “close and load to,” as shown in the following image.


Step 13: The “import data” window opens, as shown in the following image. Select the kind of output
required in the worksheet.

Since we want the output in the form of a table, select “table” and click “Ok.”

Note: One can create just a connection with the data by selecting the option “only create connection.”
When a connection is created, no output is returned in the workbook. However, the query and the steps
applied are saved. This query can be used in other queries.

Step 14: The combined data of the two text files (shown in the first image of this example) appears as a
table on the worksheet. Hence, the text files of the D drive have been imported, consolidated,
transformed, and loaded in Excel.
Step 15: One can view the list of workbook queries under the “queries and connections” pane. This
pane can be used for navigating, editing, merging, duplicating, appending, and deleting queries.

The following image shows that 601,612 rows have been loaded by Power Query in excel. Hence, by
using Power Query, a transformed output has been obtained within a short span of time.

Note 1: One can revise (modify) an existing query with the help of the “edit” option. By revising a
query, the steps applied to the data can be edited, deleted or reordered.

Note 2: One can refresh a query when new data is imported. As a query is refreshed, the associated
charts, tables, and other data forms are automatically updated.
The Key Points Related to Excel Power Query

The important points related to the usage of Power Query are listed as follows:

 Excel Power Query does not make any changes to the original (source) data file. It simply records the
transformations made to the dataset. Then, it returns the refined dataset in the workbook.
 Power Query is case-sensitive. This implies that it distinguishes between the lowercase and uppercase
versions of the same text.
 Power Query imports temporary files as well. So, such files must be excluded before the consolidation
of data. One can filter the “extension” column to exclude the temporary files.

Note: The names of the temporary files begin with the tilde symbol (~). They have the “.tmp” or
“.temp” extension.

Frequently Asked Questions


1. What is Power Query? Where and in which versions of Excel can it be found?

Power Query is an excel tool which helps in importing data from different sources, transforming it, and
producing a consolidated output. The data sources can be varied like text file, workbook, XML, JSON,
web, etc. The output is returned in an Excel workbook.

The purpose of using Power Query in excel is to obtain cleansed data which is suitable for analysis.

In Excel 2016 and the subsequent versions, Power Query can be accessed from the “get data” drop-
down (in the “get and transform data” group) of the Data tab of Excel. In Excel 2010 and 2013, Power
Query needs to be installed as an add-in. For the versions prior to Excel 2010, Power Query is not
available.

2. How to edit an already existing query in Power Query in excel?

In Power Query, an already existing query can be edited as follows:

a. From the Data tab of Excel, click “queries and connections” (in the “queries and connections”
group).

b. The “queries and connections” pane opens on the right side of the workbook. This pane shows all the
queries of the current workbook.

c. Select the name of the query to be edited. Right-click and select “edit.”

d. The “power query editor” window opens. Either edit the “applied steps” or perform new steps.

e. Once the transformations are complete, click the “close and load” button (in the “close” group) from
the Home tab of Excel.

The query is edited, saved, and updated. The dataset in the worksheet is also updated.

3. Are Power Query and Power BI the same? State the major differences between these two tools.

Power Query and Power BI are two different tools. However, Power BI desktop contains Power Query.
The major differences between Power Query and Power BI are listed as follows:

a. Power Query sorts and refines the large datasets in order to facilitate data analysis. In contrast, Power
BI is a business intelligence tool that helps visualize the data uploaded from multiple sources. These
visualizations are presented in the form of reports and dashboards.

b. Power Query reshapes data by allowing one to perform actions on it. This cleaned data is then
visualized with Power BI. Power BI also allows sharing of this visualized data. So, Excel Power Query
is used before using Power BI.

c. Power Query uses the M (Data Mash-up) language, while Power BI uses M and DAX (Data Analysis
Expressions) languages.

Note: Power BI desktop is the desktop version of Power BI, which can be downloaded for free from the
Microsoft website.
In essence, Power Query empowers Excel users to effortlessly extract, manipulate, and organize data
from an expansive array of sources, making it a game-changer for professionals dealing with complex
datasets.

Power Query be used for

Power Query is a versatile tool with a multitude of applications. Here are some common uses:

Data extraction. Connect to various data sources, including databases, Excel files, text files, and online
services.

Data transformation. A wide range of data transformation functions are available to reshape your data
into a more suitable structure for analysis, such as filtering, sorting, grouping, merging, splitting
columns into multiple fields, creating calculated columns, and more.
Data cleansing. Data quality is crucial for accurate analysis. PQ provides tools to identify and correct
errors, remove duplicates, trim extra spaces, fill missing values, and standardize formats, ensuring that
your data is clean and reliable.

Combining data. PQ makes it simple to combine and merge data from different locations into a single
cohesive dataset, facilitating comprehensive analysis.

Automating workflows. Power Query records every step you take, creating a query that can be easily
modified or reused later. This is especially useful when dealing with recurring data sources or when you
want to keep your analysis up to date with minimal effort. Also, you can refresh your query to get the
latest data from the source at any time, on demand or on a schedule.

Now that we've established what Power Query is and its potential applications, let's see how you can
get this useful feature in your Excel.

How to get Power Query in Excel

The Power Query tool is available in all modern versions, spanning from Excel 2010 to Excel 365.
Depending on the specific version you are using, you may need to install it as an add-in or access it
directly from the ribbon.

Note.. In Excel 2007 and earlier, Power Query is not supported.

How to open Power Query in Excel 2016 – 365

In newer versions of Excel, Power Query is a built-in feature, readily accessible without any additional
installations. It can be found on the Data tab under the Get & Transform Data group. To start using its
features, just click on any of the commands in this group.

How to add Power Query to Excel 2013 and 2010

In older Excel versions, Power Query is not included by default, but you can download and install it as
an add-in from the Microsoft website.
After installing the add-in and restarting Excel, you should see a new tab in the ribbon labeled Power
Query. To start importing data from various sources, click one of these buttons: From File, From
Database, From Web or From Other Sources.

Tip. Be sure to download the correct package for your version of Excel and operating system. To check
your version and bitness (32-bit or 64-bit), go to File > Account > About Excel.

Power Query Editor in Excel

The heart and soul of all data transformations lies within the Power Query Editor. It is a separate
graphical interface within Excel that plays host to your queries. It is the primary workspace where you'll
spend most of your time refining and reshaping your data.

You can access the Editor in two ways:

 On the Data tab, in the Get & Transform group, click Get Data and select Launch Power Query Editor.
 Alternatively, on the Data tab, click the Queries & Connections button to open this pane. Then, double-
click a query in the pane to launch the editor.
When you connect to a data source or create a new query, the Editor opens automatically.

Here are the six main elements of Power Query Editor:

1. Ribbon. At the top of the Editor, you'll find the Ribbon, which organizes various commands and options
across five main tabs: File, Home, Transform, Add Column, and View. Each tab has different groups of
commands that are relevant to the specific task you want to perform.
2. Queries. This is kind of navigations pane on the left side of the editor window that shows all the queries
in your workbook. You can use this pane to rename, duplicate, reference, delete, reorder or organize
your queries into groups. Just right-click on a query to see available options.
3. Data Preview. Positioned front and center, the Data Preview pane provides a snapshot of your dataset
after applying each step in your query in real-time. While its primary purpose is to facilitate data
inspection, it also allows you to perform some basic transformations, such as sorting and filtering
columns, changing data types, etc.
4. Properties. On the right-hand side of the editor window, within the Querry Settings pane, you'll find the
Properties section. It shows the properties of the selected query, such as its name, description and load
settings. Click the All Properties link to view and modify these parameters as needed.
5. Applied Steps: Just below the Properties section, there is the Applied Steps area that provides a
chronological list of all the actions you've taken during your data transformation. You can use this list to
review, edit, reorder, or delete any step in your query. You can also click on a specific step to see how it
affects your data in the data preview area.
6. Formula Bar. This is the bar at the top of the data preview area that shows the formula or expression
for the selected step in your query. You can use this bar to edit or write your own formulas using the
Power Query M language.

Advanced Power Query Editor

The Advanced Editor is a text-based interface that allows you to write and edit M code, the language
behind Power Query. Think of it as your VIP pass to the Power Query transformation backstage. While
the standard PQ interface enables you to reshape data with point-and-click actions, the Advanced Editor
gives you precise control over your data transformations.

Every action you perform in Power Query generates a corresponding code in the background, using the
M Language. You can view and edit this code in the Advanced Editor. To open it, click the Advanced
Editor button on the Home tab, in the Query group.

How to use Power Query in Excel

This section provides an overview of how to use Power Query for data analysis. You will learn the
main steps involved in importing, transforming, combining, and exporting data. These steps are:

 Get data – connect to different data sources and load them into Power Query.
 Transform – clean and reshape the data to tailor it to your specific requirements.
 Combine – merge data from various sources into a single, organized dataset.
 Write formulas – craft custom formulas using the Power Query formula language.
 Load – export your final data table to Excel and refresh it manually or automatically.

Get data

To start working with your data in Power Query, you need to import it from a source. PQ supports
many different data sources such as files, databases, online services, and more.
The three most common sources can be accessed directly from the Excel ribbon - on the Data tab, in the
Get & Transform Data group. These primary sources are:

 From Text/CSV - use this option if your data is stored in a text or CSV file.
 From Web - ideal for importing data directly from a web page.
 From Table/Range - suitable for data that's already in Excel, organized within a table or a range.

If you need to import data from other sources, click the Get Data button, and then explore further
options:

 From File - import various file types like Excel worksheets, TXT/CSV, XML, JSON, and PDF.
 From Database - connect to databases such as SQL Server or Microsoft Access.
 From Azure - access data from Azure SQL Database, Azure Data Lake Storage, and other Azure services.
 From Power Platforms - import data from Microsoft Power BI services.
 From Other Sources - this category offers even more options, including data from Excel tables/ranges,
from the web, OData feeds, ODBC, OLEDB, and others.

For example, to use a CSV file as a data source, you can either click the From Text/CSV button on the
ribbon or go a longer way: Get Data > From File > From Text/CSV. If you have multiple CSV files to
combine, save them in one folder and choose the From Folder option.

In the next screen, you'll see a preview of the imported data, along with these choices:

 Combine (for multiple files only) - lets you merge different datasets from different sources and file
types.
 Load - allows you to load the data directly into an Excel worksheet as a table, pivot table, or connection.
 Transform Data - opens the Power Query Editor, where you can make various transformations, such as
filtering, splitting, grouping, pivoting, etc. This is the option you'll use most often.
 Cancel - lets you cancel the import process and close the dialog box.

If you aim to reshape your data, the Transform Data option is the logical next step.

Transform data

Once your data is loaded into Power Query, you're in the driver's seat to refine it according to your
needs. All data transformations are done within a separate interface called the Power Query Editor,
where you have four main tabs to explore. You can think of data transformation as sculpting. You start
with a raw material that you shape into a form that suits your purpose and that allows you to create
appealing reports and dashboards.

Here are some common transformations you can perform using Power Query:

 Sort and filter. Arrange data in ascending or descending order and filter out unwanted rows to focus on
the information that matters most.
 Add, remove or duplicate columns. Modify your dataset by adding new columns, removing
unnecessary ones, or duplicating existing columns when needed.
 Change data type. You can specify the type of data in each column, such as text, number, date, time,
etc.
 Transpose row to column and vice versa. Change the orientation of your data, transforming rows into
columns for better analysis and visualization.
 Remove duplicate rows. You can eliminate any rows that have identical values in all columns to reduce
the size of your data and to avoid double-counting.
 Trim and clean. Remove leading or trailing spaces from your text values, or any extra characters that
are not part of the data to improve the quality and readability of your dataset.
 Extract values. Extract parts of your text values based on a delimiter, position, or pattern. For example,
you can extract the first name from a full name column, or the domain name from an email address
column.
 Split column. Divide a column into multiple columns based on a delimiter or a specific pattern. For
example, you can split a date column into year, month, and day columns.
 Replace or remove values or errors. You can replace any values or errors in your data with another
value, such as a blank, zero, or custom value. You can also delete any rows that contain errors or
missing values.
 Add conditional column. Create new columns based on predefined conditions, allowing for dynamic
data categorization. For example, you can create a column that assigns a category based on a numerical
range.
 Add column from example. Utilize examples to guide Power Query in creating new columns with
desired data patterns. PQ will try to infer the logic behind your examples and apply it to the rest of the
rows.
 Group and summarize data. Aggregate data by groups, calculate sums, averages, or other statistical
measures for deeper insights.

These transformations empower you to sculpt your data into a work of art that's not only functional but
also elegant and insightful. For detailed instructions, refer to this article: How to use Power Query in
Excel – practical examples.

Note. All modifications you make in the editor, collectively forming a query, constitute a new
representation of the original data. When you refresh a query, each step runs automatically, eliminating
the need to manually repeat the same actions. However, to use your refined data in Excel, you must
load it into your workbook.
Merge and combine

One of the most useful features of Power Query is the ability to combine data from different sources
into a single table. There are two main ways to do this: append and merge.

 Appending adds rows from one table to another, as long as they have the same columns. For example,
you can append sales data from different regions or months into a single table.
 Merging joins two tables based on one or more common columns (unique identifies) like a SQL join. For
example, you can merge students data from different courses based on a student name or ID column.

To combine data in the Power Query Editor, use the Merge Queries or Append Queries command, on
the Home tab, in the Combine group.
To combine data that is not in Power Query yet, click Get Data > Combine Queries on the Data tab of
the Excel ribbon, and then choose Merge or Append.

For a detailed end-to-end example of merging two tables by a common column, see How to join tables
with Power Query.

Write formulas in Power Query

Similar to using functions and formulas in Excel worksheets, PQ also has its own set of functions to
perform various calculations. These formulas are written in the Power Query formula language, also
known as M. Now, here's the great news: you don't need to learn the intricacies of M language syntax to
build your custom formulas. Unlike traditional coding, Power Query makes it wonderfully simple and
user-friendly using a visual interface.

Let’s take an example. Imagine you want to create a column that calculates the net donation amount
after tax deduction based on the values in the Donation and Tax Rate columns. The steps are:

1. Go to the Add Column tab and click on Custom Column.


2. In the Custom Column dialog box, enter “Net Donation” or any name you want for the New Column
Name
3. The Custom Column Formula box is where you write the formula itself. So, enter the following formula
in it:

=[Donation] * (1 - [Tax Rate])

To refer to a specific column in the formula, select its name under Available Columns on the
right side of the dialog and click Insert, or just double click the column name.
4. As you enter a formula, Power Query checks it, and if no errors are found, displays the message “No
syntax error have been detected”. If there’s an error in your formula, it will show an error message
indicating the error type.
5. Click OK, and the formula will be applied to all rows in the new column.
That's it! You've successfully created a custom column with a formula in Power Query. The formula bar
shows its syntax:

Load data to Excel

All the transformations you apply to your data connections collectively constitute a query, which is a
new representation of the original (and unchanged) data source. When you refresh a query, each step
runs automatically. Queries replace the need to manually connect and shape data in Excel.

Once you've performed the necessary data transformations within Power Query, the final step is to load
the resulting data into your Excel workbook. You have two options:

 From the Power Query Editor - use the Close and Load commands on the Home tab.
 From the Queries & Connections pane in Excel sheet - right-click a query and choose Load To.

The following steps show you how to do it from the Power Query Editor:

1. In the Query pane on the left, select the query you want to load.
2. On the Home tab, in the Close group, click the arrow next to Close & Load, and choose one of these
options:
o Close and Load – loads the query as a table into a new worksheet (default settings).
o Close and Load To… – lets you specify the format and location for the output.
If you select the first option, the loading process is already complete. If you choose the second
option, proceed to the next step.

3. In the Import Data dialog box, choose how you want to import the data (as Table, PivotTable or
PivotChart) and where you want to place it (in a new or existing sheet). Then click OK to finish the

process.

Excel Power Query refresh

When working with Power Query, you may need to refresh your queries from time to time to get the
latest data. Here are some ways to do that:
Refresh Power Query preview

To update the data displayed in the Power Query preview, simply click the Refresh Preview button on
the Home tab of the editor:

 Refresh Preview – updates the preview results for the current query.
 Refresh All – updates the preview results for all queries in the editor.

This will reload the data from the source to reflect any changes made to your original data. All the
changes you’ve made to the query steps will be applied to the new data automatically.

Refresh Power Query results in Excel

To refresh the Power Query results that have been loaded into an Excel workbook, do one of the
following:

 To update a specific query, right-click the query name in the Queries & Connections pane and select
Refresh.
 To refresh all queries in the workbook, press the Ctrl + Alt + F5 shortcut. Or, click the Refresh All button
on the Data tab, in the Queries & Connections
How to auto refresh Power Query without opening the file

If you need Power Query in Excel to refresh automatically without having to open the source file, you
can schedule these refreshes at specified intervals. Here's how to set it up:

1. On the Data tab, click on Queries & Connections. This will open the Queries and Connection pane on the
right side of the Excel window.
2. In the pane, right click a query that you want to schedule for automatic refresh, and then select
Properties.
3. In the Query Properties dialog box, go to the Usage tab and check the box labeled Refresh every …
minutes and enter the number of minutes.
4. Make sure the Enable background refresh option is checked.
5. To refresh the query when you open your Excel file, select the Refresh data when opening the file check
box (unselected by default).
6. Click OK to save the changes.

That’s it! From now on, your query will be refreshed automatically every time you open the workbook
or at the specified time interval, whichever comes first. This way, you can always have the latest data in
your Excel file without manually refreshing it.
These are the essentials of Excel Power Query - your secret weapon for making data work for you.
Now, you can easily connect to various data sources, transform, combine and clean your data, and then
load it into Excel or Power BI. And don't forget the cherry on top – automatic refreshes that keep your
data always up-to-date, even when you're not looking :)

You might also like