Learn to combine multiple data sources (Power Query) (2024)

In this task, you import data into your Excel workbook from the sample Northwind OData feed at http://services.odata.org/Northwind/Northwind.svc,expand the Order_Details table, remove columns, calculate a line total,transform an OrderDate, group rows by ProductID and Year, rename the query,and disable query download to the Excel workbook.

Step 1: Connect to an OData Feed

  1. Select Data > Get Data >From Other Sources > From OData Feed.

  2. In the OData Feed dialog box, enter the URL for the Northwind OData feed.

  3. Select OK.

  4. In the Navigator pane, double click the Orders table.

Step 2: Expand an Order_Details table

In this step, you expand the Order_Details table that is related to the Orders table, to combine the ProductID, UnitPrice, and Quantity columns from Order_Details into the Orders table. The Expand operation combines columns from a related table into a subject table. When the query runs, rows from the related table (Order_Details) are combined into rows with the primary table (Orders).

In Power Query, a column containing a related table has the value RecordorTable in the cell. These are called structured columns. Recordindicatesa single related record and represents aone-to-one relationship with the current data or primary table. Tableindicatesa related table and represents a one-to-many relationship with the current or primary table. A structured column represents a relationship in a data source that has a relational model. For example,a structured column indicates an entity with a foreign key association in an OData feed or foreign key relationship in a SQL Server database.

After you expand the Order_Details table, three new columns and additional rows are added to the Orders table, one for each row in the nested or related table.

  1. In Data Preview, scroll horizontally to the Order_Details column.

  2. In the Order_Details column, select the expand icon (Learn to combine multiple data sources (Power Query) (1)).

  3. In the Expand drop-down:

    1. Select (Select All Columns) to clear all columns.

    2. Select ProductID, UnitPrice, and Quantity.

    3. Select OK.

      Learn to combine multiple data sources (Power Query) (2)

      Note:In Power Query, you can expand tables linked from a column and aggregate the columns of the linked table before expanding the data in the subject table. For more information about how to perform aggregate operations, see Aggregate data from a column.

Step 3: Remove other columns to only display columns of interest

In this step you remove all columns except OrderDate, ProductID, UnitPrice, and Quantity columns.

  1. In DataPreview, select the following columns:

    1. Select the first column,OrderID.

    2. Shift+Click the last column,Shipper.

    3. Ctrl+Click the OrderDate, Order_Details.ProductID, Order_Details.UnitPrice, and Order_Details.Quantity columns.

  2. Right-click on a selected column header, and select Remove Other Columns.

Step 4: Calculate the line total for each Order_Details row

In this step, you create a Custom Column to calculate the line total for each Order_Details row.

  1. In Data Preview, select the table icon (Learn to combine multiple data sources (Power Query) (3)) at the top-left corner of the preview.

  2. Click Add Custom Column.

  3. In the Custom Column dialog box, in the Custom column formula box, enter [Order_Details.UnitPrice] * [Order_Details.Quantity].

  4. In the New column name box, enter Line Total.

  5. Select OK.

Learn to combine multiple data sources (Power Query) (4)

Step 5: Transform an OrderDate year column

In this step, you transform the OrderDate column to render the order date year.

  1. In DataPreview, right-click the OrderDate column, and select Transform > Year.

  2. Rename the OrderDate column to Year:

    1. Double-Click the OrderDate column, and enter Year or

    2. Right-Click on the OrderDate column, select Rename, and enter Year.

Step 6: Group rows by ProductID and Year

  1. In Data Preview, select Year and Order_Details.ProductID.

  2. Right-Click one of the headers, and select Group By.

  3. In the Group By dialog box:

    1. In the New column name textbox, enter Total Sales.

    2. In the Operation drop-down, select Sum.

    3. In the Column drop-down, select Line Total.

  4. Select OK.

    Learn to combine multiple data sources (Power Query) (5)

Step 7: Rename a query

Before you import the sales data into Excel, rename the query:

  • In the Query Settings pane, in the Namebox enter Total Sales.

Results: Final query for Task 2

After you perform each step, you will have a Total Sales query over the Northwind OData feed.

Learn to combine multiple data sources (Power Query) (6)

Summary: Power Query steps created in Task 2

As you perform query activities in Power Query, query steps are created and listed in the Query Settings pane, in the Applied Stepslist. Each query step has a corresponding Power Query formula, also known as the "M" language. For more information about Power Query formulas, see Learn about Power Query formulas.

Task

Query step

Formula

Connect to an OData feed

Source

= OData.Feed("http://services.odata.org/Northwind/Northwind.svc", null, [Implementation="2.0"])

Select a table

Navigation

= Source{[Name="Orders"]}[Data]

Expand the Order_Details table

Expand Order_Details

= Table.ExpandTableColumn(Orders, "Order_Details", {"ProductID", "UnitPrice", "Quantity"}, {"Order_Details.ProductID", "Order_Details.UnitPrice", "Order_Details.Quantity"})

Remove other columns to only display columns of interest

RemovedColumns

= Table.RemoveColumns(#"Expand Order_Details",{"OrderID", "CustomerID", "EmployeeID", "RequiredDate", "ShippedDate", "ShipVia", "Freight", "ShipName", "ShipAddress", "ShipCity", "ShipRegion", "ShipPostalCode", "ShipCountry", "Customer", "Employee", "Shipper"})

Calculate the line total for each Order_Details row

Added Custom

= Table.AddColumn(RemovedColumns, "Custom", each [Order_Details.UnitPrice] * [Order_Details.Quantity])

= Table.AddColumn(#"Expanded Order_Details", "Line Total", each [Order_Details.UnitPrice] * [Order_Details.Quantity])

Change to a more meaningful name, Lne Total

Renamed Columns

= Table.RenameColumns(InsertedCustom,{{"Custom", "Line Total"}})

Transform the OrderDate column to render the year

Extracted Year

= Table.TransformColumns(#"Grouped Rows",{{"Year", Date.Year, Int64.Type}})

Change to

more meaningful names, OrderDate and Year

Renamed Columns 1

Table.RenameColumns

(TransformedColumn,{{"OrderDate", "Year"}})

Group rows by ProductID and Year

GroupedRows

= Table.Group(RenamedColumns1, {"Year", "Order_Details.ProductID"}, {{"Total Sales", each List.Sum([Line Total]), type number}})

Learn to combine multiple data sources (Power Query) (2024)
Top Articles
A Guide To Retirement Planning in Canada in 2024
7 conseils pour réussir avec les ETF - Finances Indépendantes
Chs.mywork
Tattoo Shops Lansing Il
jazmen00 x & jazmen00 mega| Discover
Urist Mcenforcer
Rek Funerals
Nwi Police Blotter
Linkvertise Bypass 2023
Www Thechristhospital Billpay
Free Robux Without Downloading Apps
United Dual Complete Providers
You can put a price tag on the value of a personal finance education: $100,000
Aquatic Pets And Reptiles Photos
‘Accused: Guilty Or Innocent?’: A&E Delivering Up-Close Look At Lives Of Those Accused Of Brutal Crimes
Troy Athens Cheer Weebly
Hca Florida Middleburg Emergency Reviews
Non Sequitur
065106619
Lake Nockamixon Fishing Report
Wal-Mart 140 Supercenter Products
Free Online Games on CrazyGames | Play Now!
Acts 16 Nkjv
Roane County Arrests Today
Living Shard Calamity
Il Speedtest Rcn Net
Breckiehill Shower Cucumber
BJ 이름 찾는다 꼭 도와줘라 | 짤방 | 일베저장소
Lbrands Login Aces
Vht Shortener
Turns As A Jetliner Crossword Clue
Kristy Ann Spillane
Gesichtspflege & Gesichtscreme
Nurtsug
What does wym mean?
Little Caesars Saul Kleinfeld
Blue Beetle Movie Tickets and Showtimes Near Me | Regal
Infinite Campus Farmingdale
Great Clips Virginia Center Commons
California Craigslist Cars For Sale By Owner
Craigslist Central Il
Pain Out Maxx Kratom
Fairbanks Auto Repair - University Chevron
Quick Base Dcps
Makes A Successful Catch Maybe Crossword Clue
Matt Brickman Wikipedia
Lightfoot 247
Razor Edge Gotti Pitbull Price
Appsanywhere Mst
Festival Gas Rewards Log In
Ippa 番号
Wayward Carbuncle Location
Latest Posts
Article information

Author: Fredrick Kertzmann

Last Updated:

Views: 5507

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Fredrick Kertzmann

Birthday: 2000-04-29

Address: Apt. 203 613 Huels Gateway, Ralphtown, LA 40204

Phone: +2135150832870

Job: Regional Design Producer

Hobby: Nordic skating, Lacemaking, Mountain biking, Rowing, Gardening, Water sports, role-playing games

Introduction: My name is Fredrick Kertzmann, I am a gleaming, encouraging, inexpensive, thankful, tender, quaint, precious person who loves writing and wants to share my knowledge and understanding with you.