February 8, 2020
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.
Moderators
January 31, 2022
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.
Moderators
January 31, 2022
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.
Moderators
January 31, 2022
Moderators
January 31, 2022
Moderators
January 31, 2022
February 8, 2020
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.
1 Guest(s)