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

Community site session details

Session Id :
Power Automate - General Discussion
Answered

Compare 2 Output. If macth replace property

(0) ShareShare
ReportReport
Posted on by 19

I have 1 output  in the following format:

 

Compose Output 1

{
  "1190567550""SPACCT",
  "2016726499""SPADDR",
  "-1161693587""SPADDR",
  "-1526857583""SPACCT"
}
 
 
I have a Json Array with this format:
 
json Array B

{

"SPACCT": "@{utcNow()}",

"SPADDR": "@items('Apply_to_each')?['Acct']"

}

 

I would like an output replacing the values of compose a with the values of json Array b using without using an aply to each. The reason I have @items under array b is because this is running inside an apply each and would like to have another apply to each inside existing one.

 

Output

 

{

  "1190567550": "@{utcNow()}",
  "2016726499": "@items('Apply_to_each')?['Acct'],
  "-1161693587": "@items('Apply_to_each')?['Acct'],
  "-1526857583": "@{utcNow()}"

}

 

Thank you

I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Compare 2 Output. If macth replace property

    Hi @rojomoin 

     

    If you check out my video you will see this on a large dataset, joining without an apply to each. https://youtu.be/R_bD8nAoJ8Y 

     

    You can call the values from object 2 by using the value in object 1 as the key name.

     

    A bit like: outputs(‘compose_object2’)?[‘item()?[‘SPACCT’]] 

    Please let me know how you get on.


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

  • RM-30071752-0 Profile Picture
    19 on at
    Re: Compare 2 Output. If macth replace property

    Thank you Damien, great fan of your videos. I will be checking this video out more in detail. 

  • RM-30071752-0 Profile Picture
    19 on at
    Re: Compare 2 Output. If macth replace property

    I am struggling with getting the correct ouput. The main reason is that compose_1 property name can change and will need to be dynamic.

    The majority of examples and videos provide data where the prorperty name are static and the ouput can be mapped with different values. 

    this example Solved: Replace Property Name in One Array with Value from... - Power Platform Community (microsoft.com) is very closed to solving my problem but in this case there is a key in the property name. My key is in the value which I believe is the opposite to that example. 

    Any help would be appreciated. 

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at
    Re: Compare 2 Output. If macth replace property

    Hi @rojomoin 

     

    If you don’t know the keys of the first object, pass it to create csv table as an array and it will return the first line as a header. You can then split the header on a comma to get the key names. It would help to have a larger dataset example. A full array if that’s the case.

     

    Damien

  • Verified answer
    Chriddle Profile Picture
    8,416 Super User 2025 Season 2 on at
    Re: Compare 2 Output. If macth replace property

    Chriddle_0-1703082903404.png

    Select

    From (Get the property nodes as XML node)

    xpath(
    	xml(json(concat('{"Root":', outputs('Output_1'),'}'))),
    	'/Root/*'
    )

    Map Key (Get the node names and decode characters that are not allowed in XML node names)

    replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
    xpath(
    	item(),
    	'name(/*)'
    ),
    '_x0020_',' '),'_x0021_','!'),'_x0023_','#'),'_x0024_','$'),'_x0025_','%'),'_x0026_','&'),'_x0027_',''''),'_x0028_','('),'_x0029_',')'),'_x002A_','*'),'_x002B_','+'),'_x002C_',','),'_x002D_','-'),'_x002E_','.'),'_x002F_','/'),'_x0030_','0'),'_x0031_','1'),'_x0032_','2'),'_x0033_','3'),'_x0034_','4'),'_x0035_','5'),'_x0036_','6'),'_x0037_','7'),'_x0038_','8'),'_x0039_','9'),'_x003A_',':'),'_x003B_',';'),'_x003C_','<'),'_x003D_','='),'_x003E_','>'),'_x003F_','?'),'_x0040_','@'),'_x005B_','['),'_x005D_',']'),'_x005E_','^'),'_x005F_','_'),'_x0060_','`'),'_x007B_','{'),'_x007C_','|'),'_x007D_','}'),'_x007E_','~')

    Map Value (Get the according values from json Array B)

    outputs('json_Array_B')[
    	first(
    		xpath(
    			item(),
    			'/*/text()'
    		)
    	)
    ]

     

    Compose

    (Convert the array from the Select into an object)

    first(
    	json(
    		replace(
    			string(body('Select')),
    			'},{',
    			','
    		)
    	)
    )

     

     Output:

    {
     "1190567550": "2023-12-20T14:34:12.5453567Z",
     "2016726499": "Whatever",
     "-1161693587": "Whatever",
     "-1526857583": "2023-12-20T14:34:12.5453567Z"
    }

     

  • RM-30071752-0 Profile Picture
    19 on at
    Re: Compare 2 Output. If macth replace property

    thank you! works perfect. 

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

Coming soon: forum hierarchy changes

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
Tomac Profile Picture

Tomac 544 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 482 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 287

Last 30 days Overall leaderboard