[英]Parameter whole range or table in Excel Power Query
I have an Excel sheet with a column containing IDs of items I want to retrieve 我有一个Excel表格,其中包含要检索的项目ID的列
||ID|| || ID ||
|123| | 123 |
|124| | 124 |
|125| | 125 |
The API I am calling can take an array of IDs as input (eg https://API.com/rest/items?ID=123&ID=124&ID=125....(up to 50)) 我正在调用的API可以将ID数组作为输入(例如https://API.com/rest/items?ID = 123& ID = 124& ID = 125 ....(最多50个))
and returns one JSON. 并返回一个JSON。
"data": [
{
"id": 123,
"fields": {
"name": "blah blah",
"description": "some description",
}
},
{
"id": 124,
"fields": {
"name": "blah bli",
"description": "some description",
}
},
{
"id": 125,
"fields": {
"name": "blah blo",
"description": "some description",
}
},...
]
}
I would like to load data from this JSON in another table or sheet. 我想从另一个表或工作表中的JSON加载数据。
||ID||Name|| || ID ||名称||
|123|blah blah| | 123 |等等等等|
|124|blahblo| | 124 | blahblo |
|125|blahbli| | 125 | blahbli |
I would know how to parameterise the query by referencing single cells, but if I am retrieving 100+ items, that's a lot of work. 我会知道如何通过引用单个单元格来参数化查询,但是如果我要检索100多个项目,则需要进行大量工作。 Can't I somehow build a query that gets each value (ID) from the table or range in one simple move?
我是否能以某种简单的方式构建一个从表或范围中获取每个值(ID)的查询?
--edit1-- Found another API endpoint where I can provide an array of IDs. --edit1--找到了另一个我可以提供ID数组的API端点。 (before I thought it was only possible to send one ID per request to retrieve one JSON at a time)
(在我认为每次请求只能发送一个ID一次检索一个JSON之前)
--edit2-- Maybe I can concatenate all IDs into the request URL already in an Excel cell and parameterise just based on that one cell. --edit2--也许我可以将所有ID连接到Excel单元格中已经存在的请求URL中,并仅基于该单元格进行参数设置。 (still experimenting)
(仍在实验中)
If you've got the JSON for each ID, then you just need to pull out the name part. 如果每个ID都有JSON,则只需拉出名称部分。
For example, if you have a column [JSON]
with the JSON for each ID, then you can create a custom column using Json.Document([JSON])[data][name]
as the formula. 例如,如果您有一个
[JSON]
列,每个ID都有JSON,则可以使用Json.Document([JSON])[data][name]
作为公式来创建一个自定义列。
You can likely combine pulling the JSON and parsing it into a single step if you'd like. 如果愿意,可以将拉取JSON和解析它组合在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.