# Table.ColumnNames returns Text or List?



## absherzad (Jul 26, 2017)

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.

```
Table.ColumnNames(table as table) as {Text}
```


----------



## Ozeroth (Jul 26, 2017)

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).


----------



## absherzad (Jul 26, 2017)

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?


----------



## MarcelBeug (Jul 27, 2017)

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}:


```
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:*


```
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):


```
"Column2" meta [IsParameterQuery=true, ExpressionIdentifier=ColumnNames, Type="Text", IsParameterQueryRequired=true]
```


----------



## absherzad (Jul 27, 2017)

Thank you for clarifying. Frankly speaking I could not figure this out *Source(2,{{}}).* The following code returns type conversion error:


```
let
    Source = Excel.CurrentWorkbook(){[Name="MasterTable"]}[Content],
    #"Column Names" = Table.ColumnNames(Source(2,{{}}))
in
    #"Column Names"
```


----------



## MarcelBeug (Jul 27, 2017)

The #table(2,{{}}) part just creates an empty table with 2 columns.

You can use


```
#"Column Names" = Table.ColumnNames(Source)
```


----------



## absherzad (Jul 27, 2017)

Yes. But it does not show a list box to select a column name. One have to type the column name instead of choosing. Please see attachment.


----------



## MarcelBeug (Jul 28, 2017)

Sorry I won't check the attachment. You will get a dropdown list if you use option "edit parameters".


----------



## absherzad (Jul 30, 2017)

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


----------

