• 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
    • SALE 20% Off All Courses
    • 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Power Query Refresh Error Due to Rigid Column Names Pulled from Web |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Power Query Refresh Error Due to Rigid Column Names Pulled from Web |Power Query|Excel Forum|My Online Training Hub
                    BLACK FRIDAY SALE 20% OFF ALL COURSES
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
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 QueryPower Query Refresh Error Due to Ri…
sp_PrintTopic sp_TopicIcon
Power Query Refresh Error Due to Rigid Column Names Pulled from Web
Avatar
Ju Xu

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 6, 2019
sp_UserOfflineSmall Offline
1
September 6, 2019 - 4:37 am
sp_Permalink sp_Print

Hi Everyone,

I have a power query with the data source pulling from a website. An error happens each time I try to refresh because the column name changes accordingly by (t+1) each following day, so the refresh looks for the (t-1) column name instead of the (t+1) name which becomes an error.

To fix it, I go back to the power query editor and delete the #'Changed Type" step until the original source and refresh to pull in the new set of column names, before re-applying the #'Changed Type' step again.

Is there a way to navigate this by, for example, creating variables for each column to refresh rather than by the column name itself? 

Here is an example of what the code looks like:letSource = Web.Page(Web.Contents("website")),Data0 = Source{0}[Data],#"Changed Type" = Table.TransformColumnTypes(Data0,{{"A", type text}, {"1", type number}, {"2", type number}, {"3", type number}, {"4", type number}, {"5", type number}})in#"Changed Type"

Thank you in advance for any advice you can provide me and please let me know if my question is unclear at all. All the best!

sp_AnswersTopicSeeAnswer See Answer
Avatar
Catalin Bombea
Iasi, Romania
Member
Dashboards

Power Query

Power Pivot

Xtreme Pivot Tables

Excel for Decision Making

Excel for Finance

Excel Analysis Toolpak

Power BI

Excel

Word

Outlook

Excel Expert

Excel Customer Service
Level 10
Forum Posts: 1864
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
September 8, 2019 - 2:46 pm
sp_Permalink sp_Print

Hi Ju,

Try this instead, if all columns are type number:

= Table.TransformColumnTypes(Source, List.Transform(Table.ColumnNames(Source), each {_, type number}))

Column [A] seems to be text, you can exclude it from the number columns list, you can format it separately:

List.RemoveItems(Table.ColumnNames(Source),{"A"})

Avatar
Ju Xu

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 6, 2019
sp_UserOfflineSmall Offline
3
September 10, 2019 - 7:26 am
sp_Permalink sp_Print

Hi Catalin,

 

Thank you for your help on my query. Is there a way to keep Column [A] since I need it for reference? I have implemented this to the code for now but it excludes Column [A]. 

let
Source = Web.Page(Web.Contents("website")),
Data0 = Source{0}[Data],
#"Changed Type" = Table.TransformColumnTypes(Data0, List.Transform(Table.ColumnNames(Data0), each {_, type number}))

in
#"Changed Type"

Avatar
Catalin Bombea
Iasi, Romania
Member
Dashboards

Power Query

Power Pivot

Xtreme Pivot Tables

Excel for Decision Making

Excel for Finance

Excel Analysis Toolpak

Power BI

Excel

Word

Outlook

Excel Expert

Excel Customer Service
Level 10
Forum Posts: 1864
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
September 10, 2019 - 2:55 pm
sp_Permalink sp_Print

Hi Ju,

Why are you saying that [A] is excluded? Not seeing anything doing that in your query, it will just convert any column to type number, including [A]. If [A] has alpha chars, those rows will fail to convert, so you have to format [A] separately.

ChangeA= Table.TransformColumnTypes(Data0, {{"A", type text}})

Then, exclude [A] in the step that converts all columns to number:

#"Changed Type" = Table.TransformColumnTypes(Data0, List.Transform(List.RemoveItems(Table.ColumnNames(ChangeA),{"A"}), each {_, type number}))

sp_AnswersTopicAnswer
Answers Post
Avatar
Ju Xu

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
September 6, 2019
sp_UserOfflineSmall Offline
5
September 12, 2019 - 6:05 am
sp_Permalink sp_Print

Ah, I got it to work. Apologies for the misunderstanding and thank you very much for your work! 

All the best,

Ju

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Melissa Jamison, Pam Baillie, Todd Heckman
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Catalin Bombea: 1864
SunnyKow: 1432
Anders Sehlstedt: 886
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 241
Hans Hallebeek: 227
Jessica Stewart: 219
A.Maurizio: 213
Newest Members:
Kelvin H
Anya Ledwith
Mark Melvin
Stuart McInnes
Naji Moukhachen
Robert Mason
Debora Cohen
Kris Whitaker
Rajesh Jawajala
Todd Heckman
Forum Stats:
Groups: 3
Forums: 24
Topics: 6641
Posts: 29140

 

Member Stats:
Guest Posters: 49
Members: 33096
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
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.