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

Announcements

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,136 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 224 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 185 Super User 2026 Season 1

#3
Kalathiya Profile Picture

Kalathiya 94 Super User 2026 Season 1

Last 30 days Overall leaderboard