Table.ColumnNames returns Text or List?

absherzad

New Member
Joined
Jun 19, 2017
Messages
42
Hi everyone,
I am confused if Table.ColumnNames() returns the output as Text or List?
The documentation says it returns Text as demonstrated below, but the output looks like a List to me.
Code:
Table.ColumnNames(table as table) as {Text}
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Table.ColumnNames definitely returns a list, where each item in the list is of type text.
I guess that's what {Text} is supposed to mean (in M a list can be expressed as a comma-separated list between curly braces).
 
Upvote 0
Thanks for the input and now that is clear :)
By the way for the sake of curiosity - why when creating a new parameter with suggested values from a query uses Table.ColumnNames does not show the values as a list to choose from?
 
Upvote 0
You can verify the type of a list with function Type.ListItem.

The following query returns text, confirming that Table.ColumnNames returns a list with type {text}:

Code:
let
    Source = Table.ColumnNames(#table(2,{{}})),
    Custom1 = Type.ListItem(Value.Type(Source))
in
    Custom1

This query and parameter let's you choose a column value when editing the parameter:

Query ColumnNames:

Code:
let
    Source = Table.ColumnNames(#table(2,{{}}))
in
    Source

Parameter ColumnName (code resulting from creating a new parameter via the user interface, using output from query ColumnNames):

Code:
"Column2" meta [IsParameterQuery=true, ExpressionIdentifier=ColumnNames, Type="Text", IsParameterQueryRequired=true]
 
Upvote 0
Thank you for clarifying. Frankly speaking I could not figure this out Source(2,{{}}). The following code returns type conversion error:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="MasterTable"]}[Content],
    #"Column Names" = Table.ColumnNames(Source(2,{{}}))
in
    #"Column Names"
 
Upvote 0
The #table(2,{{}}) part just creates an empty table with 2 columns.

You can use

Code:
#"Column Names" = Table.ColumnNames(Source)
 
Upvote 0
Sorry I won't check the attachment. You will get a dropdown list if you use option "edit parameters".
 
Upvote 0
It is interesting, I did not notice the "edit parameters" options. A week ago I wrote the code properly returning the column names, however, I was wondering why the drop-down option is not available ;)

Thanks a lot :)
 
Upvote 0

Forum statistics

Threads
1,217,382
Messages
6,136,239
Members
450,000
Latest member
jgp19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top