• 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Query Expression.Error|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Query Expression.Error|Power Query|Excel Forum|My Online Training Hub
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 QueryQuery Expression.Error
sp_PrintTopic sp_TopicIcon
Query Expression.Error
Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
1
April 28, 2022 - 10:26 pm
sp_Permalink sp_Print

I get the [Expression.Error] There weren't enough elements in the enumeration to complete the operation error.  However, it is not all the time; maybe 20-25% of the refresh all times.  I am not smart enough to figure out why.  Here is the querey; any "suggestions" would be welcomed:

let

    Source = Web.Page(Web.Contents("https://"I left this blank for the help forum")),

    #"Expanded Data" = Table.ExpandTableColumn(Source, "Data", {"R", "HR", "RBI", "SB", "SO", "Team", "AB", "1B", "2B", "3B", "HBP", "CS", "IBB", "UBB", "HAB", "SV", "IP", "BS", "H", "UBB2", "HP", "ER", "SPW", "RPW", "Ho0", "Q67", "Total"}, {"R", "HR", "RBI", "SB", "SO", "Team", "AB", "1B", "2B", "3B", "HBP", "CS", "IBB", "UBB", "HAB", "SV", "IP", "BS", "H", "UBB2", "HP", "ER", "SPW", "RPW", "Ho0", "Q67", "Total"}),

    #"Filtered Rows2" = Table.SelectRows(#"Expanded Data", each ([AB] <> null)),

    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows2",{"Caption", "Source", "ClassName", "Id"}),

    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Team", type text}, {"R", Int64.Type}, {"HR", Int64.Type}, {"RBI", Int64.Type}, {"SB", Int64.Type}, {"AB", Int64.Type}, {"1B", Int64.Type}, {"2B", Int64.Type}, {"3B", Int64.Type}, {"HBP", Int64.Type}, {"CS", Int64.Type}, {"IBB", Int64.Type}, {"UBB", Int64.Type}, {"HAB", Int64.Type}, {"SV", Int64.Type}, {"SO", Int64.Type}, {"IP", type number}, {"BS", Int64.Type}, {"H", Int64.Type}, {"UBB2", Int64.Type}, {"HP", Int64.Type}, {"ER", Int64.Type}, {"SPW", Int64.Type}, {"RPW", Int64.Type}, {"Ho0", Int64.Type}, {"Q67", Int64.Type}, {"Total", type number}}),

    #"Appended Query" = Table.Combine({#"Changed Type", CurrentPeriod}),

    #"Filled Up" = Table.FillUp(#"Appended Query",{"Through", "Half", "Week", "Dates", "Overall Week"}),

    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([Team] <> null)),

    Custom1 = Table.InsertRows(#"Filtered Rows", 2, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom2 = Table.InsertRows(#"Custom1", 5, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom3 = Table.InsertRows(#"Custom2", 8, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom4 = Table.InsertRows(#"Custom3", 11, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom5 = Table.InsertRows(#"Custom4", 14, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom6 = Table.InsertRows(#"Custom5", 17, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom7 = Table.InsertRows(#"Custom6", 20, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom8 = Table.InsertRows(#"Custom7", 23, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom9 = Table.InsertRows(#"Custom8", 26, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom10 = Table.InsertRows(#"Custom9", 29, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom11 = Table.InsertRows(#"Custom10", 32, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom12 = Table.InsertRows(#"Custom11", 35, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom13 = Table.InsertRows(#"Custom12", 38, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom14 = Table.InsertRows(#"Custom13", 41, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom15 = Table.InsertRows(#"Custom14", 44, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom16 = Table.InsertRows(#"Custom15", 47, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom17 = Table.InsertRows(#"Custom16", 50, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom18 = Table.InsertRows(#"Custom17", 53, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    Custom19 = Table.InsertRows(#"Custom18", 56, {[Team=null, R=null, HR=null, RBI=null, SB=null, AB=null, 1B=null, 2B=null, 3B=null, HBP=null, CS=null, IBB=null, UBB=null, HAB=null, SV=null, SO=null, IP=null, BS=null, H=null, UBB2=null, HP=null, ER=null, SPW=null, RPW=null, Ho0=null, Q67=null, Total=null, Through=null, Week=null, Half=null, Dates=null, Overall Week=null]}),

    #"Reordered Columns" = Table.ReorderColumns(Custom19,{"Team", "Total", "R", "HR", "RBI", "SB", "AB", "1B", "2B", "3B", "HBP", "CS", "IBB", "UBB", "HAB", "SV", "SO", "IP", "BS", "H", "UBB2", "HP", "ER", "SPW", "RPW", "Ho0", "Q67", "Through", "Half", "Week", "Overall Week"}),

    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Total", "H2H Score"}, {"UBB", "UBBH"}, {"UBB2", "UBBP"}}),

    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"Through"})

in

    #"Removed Columns1"

Please forgive me; I am not the best with this stuff.  You can tell because I have repeated steps to get a "blank" row every three rows after the first adjustment.  But, it works other than the occasional Expression.Error.  Thanks.  

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 433
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
2
April 29, 2022 - 1:03 am
sp_Permalink sp_Print sp_EditHistory

Not entirely sure what you intend to do but that error occurs when you try to insert a row and the Offset element is larger than the number of rows in the current table.

In the picture below, I tried to insert a 6th row (i.e. number 5 in a zero base index) in a table that only has 4. In the previous step I successfully inserted the third row.

Screenshot-2022-04-28-170206.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Screenshot-2022-04-28-170206.png (17 KB)
Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
3
April 29, 2022 - 9:00 pm
sp_Permalink sp_Print

I know.  Hard to get the intention across.  And, I just am not that familiar with queries. The main thing with the rows, after row 2, I needed to insert a blank row every 3 rows until you see where it ends.  

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 433
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
4
April 29, 2022 - 9:19 pm
sp_Permalink sp_Print sp_EditHistory

You write "until you see where it ends". What do you mean by that? How big is your table?

But, perhaps the technique demonstrated in the attached file works for you. It splits the Source table into nested tables of three rows each into one single column. Then it inserts a row with errors at the beginning of each nested table. Once expanded, the errors are replaced by nulls resulting in empty rows. The last step is to remove the very first row.

Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
5
April 29, 2022 - 10:45 pm
sp_Permalink sp_Print

Not that large; only 60 total rows.  

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 433
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
6
April 29, 2022 - 10:46 pm
sp_Permalink sp_Print

OK, please see my previous post. I believe it could work for you.

Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
7
April 29, 2022 - 11:03 pm
sp_Permalink sp_Print

Attached is the actual query if you wanted to see the full "version."

Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
8
April 29, 2022 - 11:05 pm
sp_Permalink sp_Print

File should be here this time.

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 433
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
9
April 29, 2022 - 11:10 pm
sp_Permalink sp_Print

Thanks! I'll get back to you later. On my way out now.

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 433
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
10
April 30, 2022 - 12:08 am
sp_Permalink sp_Print

Inserted my code in your file and it seems to work fine. And it's all dynamic. If the web page contains 100 rows or perhaps only 50 rows next time, it will still work. Give it a try.

Avatar
ExcelNovice2020
Member
Members
Level 0
Forum Posts: 58
Member Since:
February 8, 2020
sp_UserOfflineSmall Offline
11
April 30, 2022 - 12:49 am
sp_Permalink sp_Print

This seems to work and I see where you are coming from.  It's not the rows I have, it's the rows of the source.  I need to take a longer look at your code as I am not familiar with that.  But, it really seemed to simplify my code a lot and I would like to do what I can to learn this.  Thank you.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: John Langham-Service, Deirdre Leigh, Suzanne Halfacre, Riny van Eekelen, John Kobiela, Manjula Mangalmurti
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Lawrence Miu
Jo Saies
Paul Pritchard
Monique Roussouw
Keith Aul
Richard Dunks
Manjula Mangalmurti
Thomas Quidort
Jamie Preece
Bob Smith
Forum Stats:
Groups: 3
Forums: 24
Topics: 6192
Posts: 27150

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • 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
 

Company

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

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.