Forum Discussion
Changing context of column reference in each statement
- 6 years ago
Put
Table.Column(Data, [Column])in the brackets for the List.Distinct
It's quite powerful but difficult to find.
The end goal for this example is a distinct/sorted list of the values in the Conference and League columns (in this example) from the Data step because they match the criteria in the "Added Custom" step by having a distinct count that is less than or equal to 5. I would expect the values to equal {"AFC", "Eastern", "NFC", "Western"} and {"NBA", "NFL", "NHL"} respectively.
The overall end goal (irrespectively of this simple example) is to understand how to dynamically reference a column name from a previous step within an each statement like this.
- pelowski6 years ago
Helper III
In the usage case I hope this will solve, I'm adding some custom columns using Lars Schreiber's article about the second parameter of Table.Profile and I'm using it in a custom function to get a better understanding of any table I pass to the custom function. One of the columns I'd like to create is a list of distinct values for any given text or numeric column that has a limited number of distinct values.
- HotChilli6 years ago
Community Champion
Put
Table.Column(Data, [Column])in the brackets for the List.Distinct
It's quite powerful but difficult to find.
- pelowski6 years ago
Helper III
Wow! It was as easy as that! Thanks!
FWIW, I swear I've been over that documentation hundreds of times but I think this is the first time I've used Table.Column! 🙄 Always learning something new! Thanks again!