Forum Discussion
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 Custom1result in
11 Replies
- Omid_Motamedise
Super User
the result of Splitposition is a list and
in this part_ >= Splitposition
you can not compare a number (_) with a list (Splitposition).
you can replace it by _ >= Splitposition{0}
but if you explain the purpose of your function I can help you more
- lbendlin
Super User
Occurrence.All will create a list.
- jimmyhua
Helper I
yes. i do want a list because there are multiple 1s in the first list. want i want to do is first to find the positions of the 1s then create fill in nulls in between each position so i can fill down and group them together. is there a way to do it?
- lbendlin
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523