Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

InsertRows giving not enough elements in the enumeration list error

Hello,

 

I am trying to add a new row to my existing table with some dummy data using insertrows function. But its invocation does not add the values to the newly added row. It gives error: "There weren't enough elements in the enumeration to complete the operation".

 

The existing table say I have "Table1" with following columns:

 

DateValue | Unique Dates | A.1 | B.1 | C.1 | D.1 | E.1 | F.1 | G.1 | H.1 | I.1 | J.1 | K.1 | L.1 | M.1| Index | Testline Dates

 

Now I am using this call in my function in the advanced query editor:

 

Table.InsertRows(#"Table1", offset, {[DateValue=nDate, Unique Dates=nDate, A.1="0",B.1="0", C.1="0", D.1="0", E.1="0", F.1="0", G.1="0", H.1="0", I.1="0", J.1="0", K.1="0", L.1="0", M.1="0", Index=nIndex, Testline Dates=TestlineDate]})

 

The resultant row added but with error for every column. Any ideas for this sort of error?

 

Expression.Error: There weren't enough elements in the enumeration to complete the operation.
Details:
[List]

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Some proper sample data would have helped.  However, you've probably got the offset wrong

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

Some proper sample data would have helped.  However, you've probably got the offset wrong

Anonymous
Not applicable

I figured it out to be the issue with offset only. It is starting with zero and I was considering it starting with one.

 

Thanks for your quick help.

Anonymous
Not applicable

Here is my function for inserting rows:

 

(NDaysToExtend as number, offset as number, LastBurndownDate as date, LastIndex as number, TestlineDate as date) =>
let
CurrentLoop = 0,
nDate = LastBurndownDate,
nIndex = LastIndex,

NewRow =

if CurrentLoop < NDaysToExtend
then
{
CurrentLoop = CurrentLoop + 1,
nDate = Date.AddDays(nDate, 1),
nIndex = nIndex + 1,

Table.InsertRows(#"Table1", offset, {[DateValue=nDate, Unique Dates=nDate, A.1="0", B.1="0", C.1="0", D.1="0", E.1="0", F.1="0", G.1="0", H.1="0", I.1="0", J.1="0", K.1="0", L.1="0", M.1="0", Index=nIndex, Testline Dates=TestlineDate]}),

 

//@InsertTrendRows(NDaysToExtend, offset, nDate, nIndex, TestlineDate),

offset = offset + 1


}
else
Type.FunctionReturn
in
NewRow

 

My ultimate aim is to call this function recursively to add multiple rows I needed based upon the number of days.

 

And the output I get is like this:

 

Table1 with inserted row:

DateValue | Unique Dates | A.1 | B.1 | C.1 | D.1 | E.1 | F.1 | G.1 | H.1 | I.1 | J.1 | K.1 | L.1 | M.1 | Index | Testline Dates
5/30/2021 | 5/30/2021 | 23 | 12 | 34 | 12 | 34 | 45 | 65 | 76 | 23 | 45 | 67 | 23 | 34 | 0 | 5/30/2021
5/31/2021 | 5/31/2021 | 12 | 23 | 45 | 32 | 34 | 65 | 23 | 56 | 78 | 90 | 23 | 76 | 23 | 1 | 5/31/2021
Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error | Error


Note that the function needs to insert new row after the above two input rows and the offset I passed is 3, index is 2 and dates would be next incremented date. Rest other values passed are to be 0. I simply don't understand why the error is shown inside the inserted row if all values are passed correctly. 

 

Any help would be appreciated.

 

Thanks

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.