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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Gandhi
Frequent Visitor

The index cannot be negative.

I have an problem (data doesn't flow). In Power Query there is 1 error table (or 2, but second one is because first).

Error is:
Expression.Error: The index cannot be negative.
Details:
Value=[List]
Index=-1


and when I go to Error, it is in step "fnGetHighestParent".

= (n as number) as number =>
let
PosOfParent = List.PositionOf( ListTeamID, n ),
ParID = ListParentID{PosOfParent}
in
if ParID = null then ListTeamID{PosOfParent} else @fnGetHighestParent(ListParentID{PosOfParent})

In Data View, there is no negative indexes. So I don't know what this error means. Does anyone has any ideas?

Thank in advance!
-G

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Gandhi 

 

List.PositionOf returns -1 if the value being searched cannot be found.  There is an optional argument in this function if this happens.  Please see this documentation: https://learn.microsoft.com/en-us/powerquery-m/list-positionof 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

1 REPLY 1
danextian
Super User
Super User

Hi @Gandhi 

 

List.PositionOf returns -1 if the value being searched cannot be found.  There is an optional argument in this function if this happens.  Please see this documentation: https://learn.microsoft.com/en-us/powerquery-m/list-positionof 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors