Forum Discussion
outteach
21 days agoNew Member
Power Query - Nested table - List.PositionOf - Find substring
This line of M code works perfectly... RowIndexOfCashFlow = Table.AddColumn(AddTableWithIndex, "Row Index of Cash Flow", each List.PositionOf([Data][Column3], "Cash Flow Analysis - Checking *7114:",...
- 20 days ago
Hard to tell without a data sample. But if your list is coming from a nested table, and there are nulls in that list (in the column of the nested table), you will see that error.
You can correct for it by changing the comparer to handle nulls:(x,y)=> Text.Contains(x ?? "",y))?? is the coalesce operator and will convert null to an empty string.
If that is not the issue, please provide a sanitized example of the actual list you are feeding into the formula. Be sure when you sanitize it that it still reproduces the error.
ronrsnfld
Super User
21 days agoYou can use the 4th argument:
List.PositionOf(Source, "Cash Flow", Occurrence.First, (x,y)=>Text.Contains(x,y))
If you use Occurrence.All, it will return a list of positions.