Forum Discussion
Power Query Custom Function how to select a list
- 2 years ago
Check this:
= (myTable as table, column as text)=> Table.TransformColumns(myTable, {{column, each Text.Combine(List.ReplaceMatchingItems(Text.Split(_, " "), {{"cat", "CAT"}, {"dog", "DOG"}}), " ")}})Now you can invoke this function by selecting a table with dropdown list and entering Column Name as text.
not sure what you mean by ' select' it.
Guessing: You can call a function from anothe query of function with its name and the parameter in parenthesis.
In your case something like
rplace =
{ { "cat", "CAT"}, {"cow", "COW"}}
= replaceallmatching(Source, rplace )assuming you named your function replaceallmatching
- Dicken2 years ago
Post Prodigy
What I mean is choose it form the invoke dialog box when you click/ select / choose a funtion a dialog box opens, form there ( x as table)=> you can choose a table , so I want to choose my replacement list in the same manner, so ( table as table, replacement list as ? ) => list does work as that askes for a table column, you cannot type the name in as that = text, so the only way so far is to just do it manually
-= functionName( tablename, listname), but is there a way to use the dialog box ,
- Dicken2 years ago
Post Prodigy
Just to add some experimnting but no luck, I thoght if I made it a tabel I could select it , so
Table.FromList( {5..7},
(A)=> {A} , type table [V = list] )= (atable as table ,C as text, Y as list )=>
let
Source = List.ContainsAll( atable, C, Y )
in
Sourcewhich looks like it should work but didn't,
the result is Query1(test, "A", Y[V]) , so text = table , "A" = column, Y[V] = numbers
not sure why doesn't work.