Hello,
I have an issue which I have trouble getting past.
I have filtered out a 'shipment' from an array with multiple shipments and I have the following array which is with my values I want to use further:
[
{
"ShipmentNumber": "1005",
"Analysis1": 23,
"Analysis2": 135655,
"Analysis3": null,
"Analysis4": 0,
"Analysis5": "10",
"Analysis6": "7",
"FlourPERC": 0.1,
"FlourProducedFrom": "zone 2, zone 4, zone 5",
"MilkPerc": 0.2,
"MilkProducedFrom": "zone 44,zone 45, zone 46, zone 47",
"YeastPerc": 0.2,
"YeastProducedFrom": "Zone 1, Zone 2, Zone 4",
"WheatPERC": 95.5,
"WheatProducedFrom": "Zone 10 , Zone 12",
}
]
What I would like is to append the following information into an array variable with the following three variables listed down below. Since these values are not constant, and there is a different composition for each product, which I would to avoid making different flows for each composition.
1. Product names, I.e "WheatPerc" without Perc.
2. The percentage of product in the end product. The value from FlourPerc, WheatPerc etc, ie value from all variables containing 'Perc'.
3. The values from all variables containing 'ProducedFrom'.
The rest of the values above "FlourPerc" are constant and not relevant, like shipmentnumber, analysis data etc.
I'm quite stuck, and can't seem to see how I can append the values I want in a good way. I've looked at something like this:
But it's appending the values containing the differnt values that are an issue.
Any help would be highly apriciated!
Edit: Typo.
Solved! Go to Solution.
Hi @Heartholme
Can you explain with a before and an after array?
Are you looking for
{
"Product Name":"Flour",
"Percentage":"0.1",
"ProducedFrom":"zone 2, zone 4, zone 5"
}
Here is how it is done.
Using a compose to hold your initial object, I have then created an array of products in another compose, including a random one - cabbage.
Then using select and the array of products as input/from, I can construct my new key/value pairs
Product Name is item()
Percentage is outputs('Object')?[concat(item(),'Perc')]
ProducedFrom is outputs('Object')?[concat(item(),'ProducedFrom')]
I use item from the array of products to create dynamic expressions.
The final array will include all products, even if not in the original object but you could filter these out using filter array action if need be as the values for percentage and producedfrom will be NULL.
Hope I've got you right - otherwise - hope you learned something 🙂
Please consider accepting my answer as a solution if it helps to solve your problem.
Cheers
Damien
Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks
Hi @Heartholme
Can you explain with a before and an after array?
Are you looking for
{
"Product Name":"Flour",
"Percentage":"0.1",
"ProducedFrom":"zone 2, zone 4, zone 5"
}
Here is how it is done.
Using a compose to hold your initial object, I have then created an array of products in another compose, including a random one - cabbage.
Then using select and the array of products as input/from, I can construct my new key/value pairs
Product Name is item()
Percentage is outputs('Object')?[concat(item(),'Perc')]
ProducedFrom is outputs('Object')?[concat(item(),'ProducedFrom')]
I use item from the array of products to create dynamic expressions.
The final array will include all products, even if not in the original object but you could filter these out using filter array action if need be as the values for percentage and producedfrom will be NULL.
Hope I've got you right - otherwise - hope you learned something 🙂
Please consider accepting my answer as a solution if it helps to solve your problem.
Cheers
Damien
Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks
This is amazing. Thanks a lot for you help!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
26 | |
26 | |
23 | |
13 | |
10 |
User | Count |
---|---|
62 | |
50 | |
30 | |
29 | |
24 |