web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Dynamic appending of v...
Power Automate
Unanswered

Dynamic appending of values containing specific strings

(0) ShareShare
ReportReport
Posted on by 1,278 Super User 2024 Season 1

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: 

Heartholme_0-1641482294824.png

But it's appending the values containing the differnt values that are an issue. 

 

Any help would be highly apriciated! 

 

Edit: Typo. 

Categories:
I have the same question (0)
  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    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"

    }


    DamoBird365_0-1641488978156.png

     

    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.

     

    DamoBird365_1-1641488996572.png

    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

     

  • Heartholme Profile Picture
    1,278 Super User 2024 Season 1 on at

    This is amazing. Thanks a lot for you help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard