• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Speeding up Power Query |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Speeding up Power Query |Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QuerySpeeding up Power Query
sp_PrintTopic sp_TopicIcon
Speeding up Power Query
Avatar
Steve Field

New Member
Members
Level 0
Forum Posts: 2
Member Since:
September 12, 2022
sp_UserOfflineSmall Offline
1
September 12, 2022 - 9:56 pm
sp_Permalink sp_Print

Hi, I have a source worksheet with 15 columns of data but when I create 'New Query' - from Excel Workbook, select the file, and the worksheet holding the data it imports 499 columns.  This import (or refresh) takes ages each time,  is there a way when doing a new query to specify only first 15 columns? (there is no data in the remaining columns). I can't change the source in advance of the query since its produced by another system and refreshed each day.

Thanks

Steve

sp_AnswersTopicSeeAnswer See Answer
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators
Level 1
Forum Posts: 616
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
September 12, 2022 - 10:52 pm
sp_Permalink sp_Print

Hi Steve,

I did a smaller scale experiment, connecting to a sheet in a workbook where I entered some data in Sheet1 in the first few columns and a space in the 50th column. Connect to the workbook, select the file name in the Navigator window (i.e. not the sheet with the data) and press Transform Data.

Then PQ will just show the workbook structure. The Data column contains a Table with the data from the worksheet you want to extract information from.

Now, you can apply the following steps:

   Source = Excel.Workbook(File.Contents("C:\Users\XX\Book3.xlsx"), null, true),
   AddedCustom = Table.AddColumn(Source, "Custom", each Table.ColumnNames([Data])),
   ColNames = List.FirstN (AddedCustom{[Item="Sheet1",Kind="Sheet"]}[Custom],15),
   Remove = Table.SelectColumns(Source,{"Data"}),
   Expand = Table.ExpandTableColumn(Remove, "Data", ColNames)
in
   Expand

Or if you want to make a bit more compact you can join the red lines of code into one.

let
   Source = Excel.Workbook(File.Contents("C:\Users\XX\Book3.xlsx"), null, true),
   ColNames = List.FirstN (Table.AddColumn(Source, "Custom", each Table.ColumnNames ([Data])){[Item="Sheet1",Kind="Sheet"]}[Custom], 15),
   Remove = Table.SelectColumns(Source,{"Data"}),
   Expand = Table.ExpandTableColumn(Remove, "Data", ColNames)
in
  Expand

This will only import the first 15 columns from my Sheet1 that actually has 50 "used" columns in it.

From here you can continue with more transformations. Hopefully this will speed up matters.

If not, let me know.

Riny

sp_AnswersTopicAnswer
Answers Post
Avatar
Steve Field

New Member
Members
Level 0
Forum Posts: 2
Member Since:
September 12, 2022
sp_UserOfflineSmall Offline
3
September 13, 2022 - 2:47 am
sp_Permalink sp_Print

Hi Riny,

I am new to using Power Query and your answer really helped (once I had realised I needed to use the Advanced Editor :-))

Very useful, many thanks

Steve

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ineke Smit, Shoua Lee, Hilary Burchfield
Guest(s) 6
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 186
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28659

 

Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.