Forum Discussion

jimmyhua's avatar
jimmyhua
Icon for Helper I rankHelper I
1 year ago
Solved

use List.Generate to create a conditional index gave me Expression.Error

I tried to create a conditional index for another list I created. here is the code I wrote and error I got.  The first list is to create a position indicator where the index can began. The first one worked. and the second one gave the error.

=[
Splitposition= List.PositionOf(List.Transform(#"Filtered Rows"[Vendor Subline Num], each _ =1), true, Occurrence.All),

Conditionalindex = List.Generate(()=>0, each _ >= Splitposition, each _ +1)

]

 

Expression.Error: We cannot apply operator < to types List and Number.
Details:
Operator=<
Left=[List]
Right=0

  • use the below formula

    let
        Source = {1,1,2,3,1,2,1,2,3,4,5,1,2,3,1,1,2},
        Custom1 = List.Transform(List.Positions(Source), each if Source{_}=1 then _+1 else null)
    in
        Custom1

    result in 

     

     

     

11 Replies