如何将数据集与PowerAutomate中的同一密钥列合并
我有两个来自两个单独的API调用的数据集。 这两个都给了我一个事件的列表和一个数值。 我想将这两组合并到PowerAutomate中的一张表中,但是我很难弄清楚如何 - 我尝试了嵌套的每个功能适用于每个功能,但这并不成功。
我的数据示例:
数组1: |事件名称|门票| | ------------- | ---------- | |一般入学| 510 | |会员| 210 | |特殊程序| 100 | |组| 20 |
数组2: |事件名称|签入| | ------------- | ---------- | |一般入学| 210 | |会员| 110 | |特殊程序| 100 |
(这些数据的格式,数组或字符串:[{“事件名称”:“常规入学”,“购买票证”:“ 510”},{“事件名称”:“成员”,购买的票证“:“ 210”} ....]
和[{“事件名称”:“常规入学”,“在”:“ 210”}中检查,.....]
)
我想做的就是将它们合并为: |事件名称|门票|签入| | -------------- | ------------------------------- | |一般入学| 510 | 210 | |会员| 210 | 110 | |特殊程序| 100 | 100 | |组| 20 | |
(理想情况下,最后一个单元格是0,但这是我可以弄清楚的)。重要的是要注意,这两个表都可能没有相同的行,我只想将其视为null。我对的控制不大,我得到的键值,这些值取决于RAN报告。但是,如果它们 do 匹配,则密钥将相同。
Union
只需在第一个数插入第二个数组,然后我获得了一个带有两组键值的表,分别为第2列和第3列。我认为Inner-Join
可以帮助我解决这个问题,但似乎并没有给我选择两个数组的选项。
我无法访问任何PowerAutomate Premium功能
I have two data sets coming from two separate API calls.
These both give me a list of events, and a number value.
I want to merge these two sets into one table, in PowerAutomate, but I am having trouble figuring out how -- I've tried a nested Apply to Each function but it's not successful.
Example of my data:
Array 1:
| Event Name | Tickets |
|------------|---------|
| General Admission | 510 |
| Members | 210 |
| Special Programs | 100 |
| Groups | 20 |
Array 2:
| Event Name | Checked In|
|------------|---------|
| General Admission | 210 |
| Members | 110 |
| Special Programs | 100 |
(these data are in JSON format, arrays or strings: [{ "Event Name": "General Admission", "Purchased Tickets": "510"},{"Event Name": "Members", "Purchased Tickets": "210"}....]
and [{"Event Name": "General Admission", "Checked In": "210"},.....]
)
And what I want to do is merge them into:
| Event Name | Tickets | Checked In |
|------------|---------|------------|
| General Admission | 510 | 210 |
| Members | 210 | 110 |
| Special Programs | 100 | 100 |
| Groups | 20 | |
(ideally the last cell would be 0 but that's something I can figure out myself). The important thing there is to note that both tables might not have identical rows, I just want to treat it as a null for now if so. I don't have a lot of control over what key values I get, those are dependant on the ran reports. However if they do match, the keys will be identical.
union
just plops the second array after the first, and then I get a table with two sets of key values, and blank for column 2 and 3 respectively. I think inner-join
can help me with this but it doesn't seem to give me an option to select both arrays.
I don't have access to any PowerAutomate premium features
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的流程将为您做。我不得不说,这种操纵就像您想做的那样,在LogicApps/PowerAutomate引擎上并不总是理想的。无论哪种方式...
描述每个步骤...
基本数据
这只是您的JSON,它是您要使用新数据集增加的基本数据。
查找数据
这是其他数据集,指出最后一个记录没有
checkedin
属性。显然,这是流程的重要组成部分。初始化的组合数组
在此阶段是空的,它将将数据结合在连接状态。
处理每个基本数据项
这很明显,我们只是通过
基本数据
数组进行循环。当前基本数据项上的过滤器查找数组
可视化此操作要容易一些。
要向您展示该步骤背后的代码...
附加到组合数组的
方法有几种方法可以做到这一点,但要更好地说明它,我们只是创建一个新对象并将其添加到
组合数组
变量。这是步骤中包含的代码...
重要的表达式是
checkedin
属性。它检查过过滤器结果是否至少具有一个值,如果有的话,它将获得第一个(使用索引0,但您可以使用
first
函数)项目(我假设只有一个)然后从中获取checkedin
属性。最终结果是一个看起来像这样的数组...
A flow such as this will do it for you. I have to say, this type of manipulation like you're wanting to do is not always ideal on the LogicApps/PowerAutomate engine. Either way ...
To describe each step ...
Base Data
This is simply your JSON that is the base data you want to augment with the new data set.
Lookup Data
This is the other data set noting that the last record has no
CheckedIn
property. Obviously, that's an important part of the flow.Initialized Combined Array
This is empty at this stage, it will combine the data in a joined state.
Process Each Base Data Item
This is obvious, we're just looping through the
Base Data
array.Filter Lookup Array on Current Base Data Item
It's a bit easier to visualise this action.
To show you the code behind that step ...
Append to Combined Array
There are a couple of ways to do this but to illustrate it all a bit better, we're simply creating a new object and adding that to the
Combined Array
variable.This is the code contained within the step ...
The important expression being the
CheckedIn
property.It checks to see if the filter result had at least one value, if it does, it gets the first (using index 0 but you could use the
first
function) item (I assume there should only be one) and then gets theCheckedIn
property from that.The end result is an array that looks like this ...