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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding a calculated co...
Power Automate
Answered

Adding a calculated column to array

(1) ShareShare
ReportReport
Posted on by 5
Hi,
I have this array that has two columns, "Price" and "Quantity"
<root>
  <array>
    <Product>A
    </Product>
    <Price>120
    </Price>
    <Quantity>45307
    </Quantity>
  </array>
  <array>
    <Product>B
    </Product>
    <Price>58
    </Price>
    <Quantity>2530
    </Quantity>
  </array>
  <array>
    <Product>C
    </Product>
    <Price>165
    </Price>
    <Quantity>685
    </Quantity>
  </array>
</root>
 
I would like to add a calculated column to this array to calculate the total value for each product, "Value" = Price * Quantity. I am looking for a XPath solution rather than "Apply to each", if possible.
 
Thanks.
Categories:
I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at
     
    Try like as shown below
     
    1. Use a compose action to store the xml input
     
    2. Use Select action to perform the calculated column operation as shown below
    Expression: 
    json(xml(outputs('Compose')))?['root/array']
     
     
    Expression: 
    addProperty(item(),'Value',string(mul(float(item()?['Price']),float(item()?['Quantity']))))
     
     
    3. Use a compose action to structure the array like below
     
    4. use compose action to convert the json in above compose action to xml.
     
     
    Final XML looks like this
    <root><array><Product>A</Product><Price>120</Price><Quantity>45307</Quantity><Value>5436840</Value></array><array><Product>B</Product><Price>58 </Price><Quantity>2530</Quantity><Value>146740</Value></array><array><Product>C</Product><Price>165</Price><Quantity>685 </Quantity><Value>113025</Value></array></root>

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

  • CU20021609-0 Profile Picture
    5 on at
    Thanks @Nived_Nambiar. This is exactly what I was looking for,

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 410

#2
Vish WR Profile Picture

Vish WR 289

#3
David_MA Profile Picture

David_MA 282 Super User 2026 Season 1

Last 30 days Overall leaderboard