Create, load, or edit a query in Excel (Power Query) (2024)

Skip to main content

Microsoft

Support

Support

Sign in

Sign in with Microsoft

Sign in or create an account.

Hello,

Select a different account.

You have multiple accounts

Choose the account you want to sign in with.

Excel

Import and analyze data

Import data

Import data

Create, load, or edit a query in Excel (Power Query)

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 More...Less

Power Query offers several ways to create and loadPower queries into your workbook. You can also set default query load settings in the Query Options window.

Tip To tell if data ina worksheetis shaped by Power Query, select a cell of data, and if the Query context ribbon tab appears, then the data was loaded from Power Query.

Create, load, or edit a query in Excel (Power Query) (2)

Know which environment you're in Power Query is well-integrated into the Excel user interface, especially when you import data, work with connections, and edit Pivot Tables, Excel tables, and named ranges. To avoid confusion, it’s important to know which environment you are currently in, Excel or Power Query, at any point in time.

The familiar Excel worksheet , ribbon, and grid

The Power Query Editor ribbon and data preview

Create, load, or edit a query in Excel (Power Query) (3) Create, load, or edit a query in Excel (Power Query) (4)

For example, manipulating data in an Excel worksheet is fundamentally different than Power Query. Furthermore, the connected data that you see in an Excel worksheet, may or may not have Power Query working behind the scenes to shape the data. This only occurs when you load the data to a worksheet orData Modelfrom Power Query.

Rename worksheet tabs It’s a good idea to rename worksheet tabs in a meaningful way, especially if you have a lot of them. It’s particularly important to clarify the difference between a worksheet of data, and a worksheet loaded from the Power Query Editor. Even if you have only two worksheets, one with an Excel table, called Sheet1, and the other a query created by importing that Excel table, called Table1, it’s easy to get confused. It’s always good practice to change the default names of worksheet tabs to names that make more sense to you. For example, rename Sheet1 to DataTable and Table1 to QueryTable. Now it’s clear which tab has the data and which tab has the query.

You can either create a query from imported data or create a blank query.

Create a query from imported data

This is the most common way to create a query.

  1. Import some data. For more information, see Import data from external data sources.

  2. Select a cell in the data and then select Query > Edit.

Create a blank query

You may want to just start from scratch. There are two ways to do this.

  • Select Data > Get Data > From Other Sources > Blank Query.

  • Select Data > Get Data > Launch Power Query Editor.

At this point, you can manually add steps and formulas if you know the Power Query M formula languagewell.

Or you can select Home and then select a command in the New Query group. Do one of the following.

  • Select New Source to add a data source. This command is just like the Data > Get Data command in the Excel ribbon.

  • Select Recent Sources to select from a data source you have been working with. This command is just like the Data > Recent Sources command in the Excel ribbon.

  • Select Enter Data to manually enter data. You might choose this command to try out the Power Query Editor independent of an external data source.

Assuming your query is valid and has no errors, you can load it back to a worksheet or Data Model.

Load a queryfrom the Power Query Editor

In the Power Query Editor, do one of the following:

  • To load to a worksheet, select Home > Close & Load > Close & Load.

  • To load to a Data Model, select Home > Close & Load > Close & Load To.

    In the Import Data dialog box, select Add this data to the Data Model.

Tip Sometimes the Load To command is dimmed or disabled. This can occur the first time you create a query in a workbook. If this occurs, select Close & Load, in the new worksheet, select Data > Queries & Connections > Queries tab, right click the query, and then select Load To. Alternatively, on thePower Query Editor ribbon select Query > Load To.

Load a query from the Queries and Connections pane

In Excel, you may want to load a query into another worksheet or Data Model.

  1. In Excel, select Data > Queries & Connections, and then select the Queries tab.

  2. In the list of queries, locate the query, right click the query, and then select Load To. TheImport Data dialog box appears.

  3. Decide how you want to import the data, and then selectOK. For more information about using this dialog box, select the question mark (?).

There are several ways to edit a query loaded to a worksheet.

Edit a query from data in Excel worksheet

  • To edit a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit.

Edit a query from the Queries & Connections pane

You may find the Queries & Connections pane is more convenient to use when you have many queries in one workbook and you want to quickly find one.

  1. In Excel, select Data > Queries & Connections, and then select the Queries tab.

  2. In the list of queries, locate the query, right click the query, and then select Edit.

Edit a query from the Query Properties dialog box

  • In Excel, select Data > Data & Connections > Queries tab, right click the query and select Properties, select the Definition tab in the Properties dialog box, and then select Edit Query.

Tip If you are in a worksheet with a query, select Data > Properties, select theDefinition tabin the Properties dialog box, and then select Edit Query.

A Data Model typically contains several tables arranged in a relationship. You load a query to a Data Model by using the Load To command to display the Import Data dialog box, and then selecting the Add this data to the Data Model check box. For more information about Data Models, see Find out which data sources are used in a workbook data model, Create a Data Model in Excel, and Use multiple tables to create a PivotTable.

  1. To open the Data Model, select Power Pivot>Manage.

  2. At the bottom of the Power Pivot window, select the worksheet tab of the table you want.

    Confirm that the correct table displays. A Data Model can have many tables.

  3. Note the name of the table.

  4. To close the Power Pivot window, select File > Close. It may take a few seconds to reclaim memory.

  5. Select Data > Connections & Properties > Queries tab, right click the query, and then select Edit.

  6. When finished making changes in the Power Query Editor, select File > Close & Load.

Result

The query in the worksheet and the table in the Data Model are updated.

If you notice that loading a query to a Data Model takes much longer than loading to a worksheet, check your Power Query steps to see if you are filtering a text column or a List structured column by using a Contains operator. This action causes Excel to enumerate again through the entire data set for each row. Furthermore, Excel can’t effectively use multithreaded execution. As a workaround, try using a different operator such as Equals or Begins With.

Microsoft is aware of this problem and it is under investigation.

You canload a Power Query:

  • To a worksheet. In the Power Query Editor, select Home > Close & Load > Close & Load.

  • To a Data Model.In the Power Query Editor, select Home > Close & Load > Close & LoadTo.

    By default, Power Query loads queries to a new worksheet when loading a single query, and loads multiple queries at the same time to the DataModel. You can change the defaultbehavior for all your workbooks or just the current workbook.When setting these options, Power Query doesn't changequery results in the worksheet or the Data Model data and annotations.

    You can also dynamically override the default settings for a query by using the Import dialog box which displays after you selectClose & LoadTo.

Global settings that apply to all your workbooks

  1. In the PowerQuery Editor, select File > Options and settings > Query Options.

  2. In the Query Options dialog box, on the left side, under theGLOBALsection, select Data Load.

  3. Under theDefault Query Load Settings section, do the following:

    • SelectUse standard load settings.

    • Select Specify custom default load settings,and then select or clear Load to worksheet or Load to Data Model.

Tip At the bottom of the dialog box, you can select Restore Defaults to conveniently return to the default settings.

Workbook settings that only apply to the current workbook

  1. In the Query Options dialog box, on the left side, under the CURRENTWORKBOOKsection, select Data Load.

  2. Do one or more of the following:

    • Under Type Detection, select or clear Detect column types and headers for unstructured sources.

      The default behavior is to detect them. Clear this option if you prefer to shape the data yourself.

    • Under Relationships, select or clear Create relationships between tables when adding to the Data Model for the first time.

      Before loading to the Data Model, the default behavior is to find existing relationships between tables, such as foreign keys in arelational database and import them with the data. Clear this option if you prefer to do this on your own.

    • Under Relationships, select or clear Update relationships when refreshing queries loaded to the Data Model.

      The default behavior is to not update relationships. When refreshing queries already loaded to the Data Model, Power Query finds existing relationships between tables such as foreign keys in a relational database and updates them. This might remove relationships created manually after the data was imported or introduce new relationships. However, if you want to do this, select the option.

    • Under Background Data, select or clear Allow data previews to download in the background.

      The default behavior is to download data previews in the background. Clear this option if you can want to see all the data right away.

See Also

Power Query for Excel Help

Manage queries in Excel

Need more help?

Want more options?

Discover Community

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Create, load, or edit a query in Excel (Power Query) (5)

Microsoft 365 subscription benefits

Create, load, or edit a query in Excel (Power Query) (6)

Microsoft 365 training

Create, load, or edit a query in Excel (Power Query) (7)

Microsoft security

Create, load, or edit a query in Excel (Power Query) (8)

Accessibility center

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Create, load, or edit a query in Excel (Power Query) (9)

Ask the Microsoft Community

Create, load, or edit a query in Excel (Power Query) (10)

Microsoft Tech Community

Thank you for your feedback!

×

Create, load, or edit a query in Excel (Power Query) (2024)
Top Articles
Loaded Cost of Employee Time
To delete one word to the right ____________.CTRL+SHIFTCTRL+TABCTRL+DELCTRL+Z
Pnct Terminal Camera
Uihc Family Medicine
Mcfarland Usa 123Movies
T Mobile Rival Crossword Clue
Body Rubs Austin Texas
Bucks County Job Requisitions
Is Sportsurge Safe and Legal in 2024? Any Alternatives?
Bluegabe Girlfriend
Wfin Local News
Lowes 385
Irving Hac
Strange World Showtimes Near Cmx Downtown At The Gardens 16
Boat Jumping Female Otezla Commercial Actress
Jscc Jweb
Syracuse Jr High Home Page
Walthampatch
Seattle Rpz
Fool’s Paradise movie review (2023) | Roger Ebert
Mzinchaleft
Pizza Hut In Dinuba
1-833-955-4522
Kp Nurse Scholars
How pharmacies can help
Ruben van Bommel: diepgang en doelgerichtheid als wapens, maar (nog) te weinig rendement
Fort Mccoy Fire Map
Tips on How to Make Dutch Friends & Cultural Norms
Jail View Sumter
Mega Personal St Louis
Renfield Showtimes Near Paragon Theaters - Coral Square
Account Now Login In
Royalfh Obituaries Home
Puffin Asmr Leak
Prévisions météo Paris à 15 jours - 1er site météo pour l'île-de-France
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Jr Miss Naturist Pageant
No Hard Feelings Showtimes Near Tilton Square Theatre
Final Exam Schedule Liberty University
Indio Mall Eye Doctor
Lucyave Boutique Reviews
Citizens Bank Park - Clio
Victoria Vesce Playboy
Take Me To The Closest Ups
Okta Login Nordstrom
Mlb Hitting Streak Record Holder Crossword Clue
116 Cubic Inches To Cc
Craigslist Psl
Craigslist Indpls Free
Latest Posts
Article information

Author: Francesca Jacobs Ret

Last Updated:

Views: 6280

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Francesca Jacobs Ret

Birthday: 1996-12-09

Address: Apt. 141 1406 Mitch Summit, New Teganshire, UT 82655-0699

Phone: +2296092334654

Job: Technology Architect

Hobby: Snowboarding, Scouting, Foreign language learning, Dowsing, Baton twirling, Sculpting, Cabaret

Introduction: My name is Francesca Jacobs Ret, I am a innocent, super, beautiful, charming, lucky, gentle, clever person who loves writing and wants to share my knowledge and understanding with you.