问题描述
我需要根据另一列中的值在列中写入序列/索引。 请在下面找到示例来解释我的请求: 在这里,我需要根据 color 列中的值在 customindex 列中生成索引值..所以基本上如果列中有 4 行带有红色,那么它应该将行索引为 1,2,3,4 然后当它2 行以蓝色为值,它应该再次从 1 -> 1,2 索引。
输入数据:
[
{
"Type": "Header","Color": "Red","Customindex": ""
},{
"Type": "Header","Color": "Blue",{
"Type": "LineItem","Color": "Yellow","Customindex": ""
}
]
这是我需要帮助的转换:
%dw 2.0
output application/json
var TM = flatten(payload map ((item,index) ->
[{
"Type":payload.type,//HEADER VALUES
"Color":"","Customindex":""
}]++
[{
"Type":payload.type,// LINE ITEM VALUES
"Color":payload.color,"Customindex":index // need the index sequence to only count similar colors.. For ex : red start with 1,3 then for blue again 1,2 and so on
}]))
---
(((TM distinctBy $ ... filters and groupings
包含详细信息的示例数据(这是预期的输出):
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)