Forum Discussion
npust333
2 years agoNew Member
Dynamically use IF statement to update a variable
Hello, I have a use case that I would like some help with Every period, I will receive a PDF statement, and my task is to extract the content of that PDF and populate it to Excel. The problem is, ...
- 2 years ago
pos = List.PositionOf( Table.ToRows(Source), "Name", Occurrence.First, (x, y) => List.Contains(x, y) )finds first occurrence of "Name" in ANY column. If you really want narrow your search by first 2 columns (and make it less dynamic) then make this change in the code: List.Contains(List.FirstN(x, 2), y)
AlienSx
2 years agoSuper User
pos = List.PositionOf(
Table.ToRows(your_table),
{"Name", "Date", "Class", "Category"},
Occurrence.First,
(x, y) => List.ContainsAll(x, y)
)- npust3332 years agoNew Member
Hi AlienSx , thanks for the answer.
Is there a way to make it dynamic as we don't know how many columns will be there?
One pattern i notice from the files i received is that the "Name" value that i will look at is either in column1 or column 2 only, so the search can be reduced to only that scope
- AlienSx2 years agoSuper User
pos = List.PositionOf( Table.ToRows(Source), "Name", Occurrence.First, (x, y) => List.Contains(x, y) )finds first occurrence of "Name" in ANY column. If you really want narrow your search by first 2 columns (and make it less dynamic) then make this change in the code: List.Contains(List.FirstN(x, 2), y)