Dan Bliss
New member
- Joined
- Dec 7, 2016
- Messages
- 45
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- Office 365
Table.Profile is a neat function for showing basic descriptive statistics of each column in a table. I want to wrap this in a custom function, "ListNonNullColumns", so I can easily see which columns in my table have data. I want to pass the table name to the function. How do I do this properly?
Try #1: where aTable is "Any" type.
Invoking ListNonNullColumns produces this, which has error:
Hand corrected to:
To eliminate the error passing text when I need to pass a table, I change the type of the parameter:
Try #2: where aTable is type table
The function itself has no errors, but if invoked by typing Table11 into "Enter parameter" text field in UI, Power Query complains "Enter a Table Value". Entering #Table11 does not help.
So what is the correct function parameter syntax?
Try #1: where aTable is "Any" type.
Code:
(aTable) =>
let
Source = Table.Profile(aTable),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Average", type number}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Average] <> null))
in
#"Filtered Rows"
Invoking ListNonNullColumns produces this, which has error:
Code:
let
Source = ListNonNullColumns("Table11")
in
Source
Code:
let
Source = ListNonNullColumns(Table11)
in
Source
To eliminate the error passing text when I need to pass a table, I change the type of the parameter:
Try #2: where aTable is type table
Code:
(aTable as table) =>
So what is the correct function parameter syntax?