Forum Discussion
Iterating / changing query parameter to build a merged table
- 8 years ago
Well done! So if you have the function already, all that's left to do is to
1) transform your list of ClientIDs to a table (tab: List Tools -> Convert -> To Table) and
2) add a column (tab: Add Column -> General -> Custom Column
3) In the dialogue, call you function (for each row), passing [Column1] as the parameter that holds the Client ID
4) Expand that column
Well done! So if you have the function already, all that's left to do is to
1) transform your list of ClientIDs to a table (tab: List Tools -> Convert -> To Table) and
2) add a column (tab: Add Column -> General -> Custom Column
3) In the dialogue, call you function (for each row), passing [Column1] as the parameter that holds the Client ID
4) Expand that column
- rmjersey8 years agoNew Member
Thank you so much ImkeF :smileyvery-happy:, very close to a solution now...
Some of the fields in the new column show as Error (because there are no workstations):
"Expression.Error: There weren't enough elements in the enumeration to complete the operation."
I therefore cannot expand the column yet.
Does this need to be fixed in the code for my Function (so that the function always returns someting even if there are no workstations?)
Or is there something I can do in the Table.ExpandTableColumn code to deal with that case?
Thanks,
Richard
- ImkeF8 years agoCommunity Champion
Easiest would probably be to use an error handler: try YourFunctionCall otherwise null
This would make the code of that step look like this:
Table.AddColumn(YourPreviousStep, "Custom", each try YourFunction([Column1]) otherwise null)
- ImkeF8 years agoCommunity Champion
BTW: You can also iterate a list "the traditional way" using List.Transform: https://msdn.microsoft.com/en-us/library/mt253641.aspx
But the advantage of the Table.AddColumn-method in my eyes is that the ClientID is kept in a separate field.
:-)
- v-huizhn-msft8 years agoMicrosoft Employee
Hi rmjersey,
Have you resolved your issue? If you have, welcome to share your own solution, or mark the right/helpful reply as answer. More people will learn new things here. If you haven't, please feel free to ask.
Best Regards,
Angelia