Forum Discussion
vikas-jk
6 years agoRegular Visitor
How to get Columna name from list using mQuery power query
I have data coming from api and then converted as List using mQuery. Now I want to get column names from api ( column names are dynamic), how do I get it. Expand= List.Generate(()=>
...
- 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
)
)
)
ImkeF
6 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-jk
6 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"
}
]