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 ,
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?
Here is the screenshot of error
I am using Visual Studio to create custom connector you can see error in the "Errors" tab.
- ImkeF6 years agoCommunity Champion
Hi vikas-jk ,
I still believe that it has something to do with what your query returns (as my code does what the example showed).
So please adjust your connector and show what's actually returned as an input for the next step:
- vikas-jk6 years agoRegular Visitor
This is sample JSON data, which is returned from server. There are lots of user's I have shown you only 2 out of 100.
[ { "id": 1, "firstName": "User 1", "lastName": "Last name", }, { "id": 2, "firstName": "User 2", "lastName": "lastname 2" } ]