How to convert function parameter from text to Table Column reference

Dan Bliss

New member
Joined
Dec 7, 2016
Messages
45
Reaction score
0
Points
0
Excel Version(s)
Office 365
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

Code:
(aTable, ColumnName as text) =>let
    resultList = Table.Column
        (
        Table.SelectRows
            (
            Table.Distinct
                (
                aTable,{ColumnName}
                )
            , each ([B][COLOR=#ff0000][ColumnName][/COLOR][/B] <> null)
            ), ColumnName
        )
in
    resultList
 
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.
 
Back
Top