This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
PSB piece of PQ code
let
MyList = { 5, 10, 15, 20 },
Index = -1,
Found = (Index = List.PositionOf(MyList, 15)) <> -1
in
[Found in Array = Found, Array Location = Index]
This results in the following output
[TRUE, -1]
I am trying to wrap my head around how Found can be TRUE and still Index is -1.
Hi @Anonymous
This might be useful as well.
https://docs.microsoft.com/en-us/powerquery-m/evaluation-model
Actually I want the ability to be able to get the index of an element in a list (say list A) in 1 condition and use the returned index to access a diferent list (list B) all within an each statement. Without repeating the List.PositionOf in the second condition again, it does not seem possible.
Just use List.Transform e.g.
= each List.Transform([MyListColumn], (elm) => [MyOtherListColumn]{elm})
The thing to note is that "each" is just shorthand for "(_) =>" and "_" is the default variable, so that where "[Column]" is, it just is shorthand for "_[Column]"
Hi @Anonymous
The original index was not overridden because it's been changed only within Found, so technically you referred to the original state within your output.
The below will make more sense
let
MyList = { 5, 10, 15, 20 },
Index = List.PositionOf( MyList, 15 ),
Found = Index <> -1
in
[Found in Array = Found, Array Location = Index]
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |