PDA

View Full Version : How to convert function parameter from text to Table Column reference



Dan Bliss
2017-02-07, 09:17 PM
Hello, Please help:

I want my M (Power Query) function to return a list of unique values taken from a particular column in a table. The red [ColumnName], part of a condition clause, does not work. Can anyone help me with the correct syntax/function to turn the text value in ColumnName to the correct Table column reference?

Thanks.
Dan


(aTable, ColumnName as text) =>let
resultList = Table.Column
(
Table.SelectRows
(
Table.Distinct
(
aTable,{ColumnName}
)
, each ([ColumnName] <> null)
), ColumnName
)
in
resultList

MarcelBeug
2017-02-28, 07:27 AM
This question was cross posted and answered on the Technet Power Query forum.
Unfortunately I'm not allowed to paste a link as I have only 2 posts on this forum and a minimum of 5 posts is required to paste a link. But the post has the same title.

MarcelBeug
2017-02-28, 07:27 AM
Dummy post #4.

MarcelBeug
2017-02-28, 07:29 AM
Dummy post #5.

MarcelBeug
2017-02-28, 07:30 AM
My apologies for the dummy posts, but now I can include the link to the topic on the Technet forum (https://social.technet.microsoft.com/Forums/en-US/df399ef1-d4f9-4c3d-9c99-801c631c2ee5/how-to-convert-function-parameter-from-text-to-table-column-reference?forum=powerquery).