Forum Discussion
How to get Columna name from list using mQuery power query
- 6 years ago
Hi vikas-jk ,
if all tables have the same name you can grab it from the first table like so:
Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(tableOfPages[Column1]{0}) )otherwise you have to query over whole column like so:
Table.ExpandTableColumn(
tableOfPages,
"Column1",
List.Distinct(List.Transform(
tableOfPages[Column1],
Table.ColumnNames
)
)
)
Hi vikas-jk ,
if all tables have the same name you can grab it from the first table like so:
Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(tableOfPages[Column1]{0}) )
otherwise you have to query over whole column like so:
Table.ExpandTableColumn(
tableOfPages,
"Column1",
List.Distinct(
List.Transform(
tableOfPages[Column1],
Table.ColumnNames
)
)
)
I tried both of your above solution, getting same error in both "we cannot convert value of type list into table"
shared ColumnsCheck.Contents = (optional message as text) =>
let
Expand= List.Generate(()=>
[Result= try GetData(1,2) otherwise null],
each [Result] <> null,
each [Result = try GetData(1,2) otherwise null],
each [Result]),
tableOfPages = Table.FromList(Expand, Splitter.SplitByNothing(), {"Column1"}),
output=Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(tableOfPages[Column1]{0}) )
in
output;What is wrong with the above query?
- ImkeF6 years agoCommunity Champion
Hi vikas-jk ,
then the column you're trying to expand doesn't contain what I expected it to contain.
If it would contain tables, my code would work as you can see if you paste this code into the advanced editor and follow the steps:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSixOUdJRSi0qUYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}), Custom1 = #table({"Column1"}, {{#"Changed Type"}, {#"Changed Type"}}), #"Expanded Column1" = Table.ExpandTableColumn(Custom1, "Column1", Table.ColumnNames(Custom1[Column1]{0})) in #"Expanded Column1"It is very hard to debug without seeing the data.
Could you share a screenshot of the data before the step that produces the error?- vikas-jk6 years agoRegular Visitor
Here is the screenshot of error
I am using Visual Studio to create custom connector you can see error in the "Errors" tab.