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 / Arrange the data verti...
Power Automate
Unanswered

Arrange the data vertically using excel formula or macro or power automate

(0) ShareShare
ReportReport
Posted on by 56

Hi Everyone

 

Good day

 

Is it possible to arrange the data below.

main data

Customer CodeCustomer NameProductQuantity 1Quantity2Quantity3Quantity4
1234JohnApple2

3

 

3 
1234JohnMango102 
1234JohnPeach221 
12345CarlApple21  
12345CarlMango53  
678BenPeach1341
678BenMango5342

 

Result (I want to combine all the quantity in one column only) vertically.

Customer CodeCustomer NameProductQuantity 1
1234JohnApple2
1234JohnMango1
1234JohnPeach2
1234JohnApple3
1234JohnMango0
1234JohnPeach2
1234JohnApple3
1234JohnMango2
1234JohnPeach1
12345CarlApple2
12345CarlMango5
12345CarlApple1
12345CarlMango3
678BenPeach1
678BenMango5
678BenPeach3
678BenMango3
678BenPeach4
678BenMango4
678BenPeach1
678BenMango2
I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @GPT2 ,

     

    Do you want sum all the quantities or do you want to write as below 

    Customer CodeCustomer NameProductQuantity 1
    1234JohnApple2,3,3

     

    Regards,

    Vishnu Reddy

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @GPT2 

     

    Please follow the below approach:

    Deenuji_0-1714370736804.png

     

    Product Table:

    Deenuji_1-1714370788215.png

     

    Resulted Datatable:

    Deenuji_2-1714370842969.png

     

    Code:

    SET resultTable TO { ^['Customer Code', 'Customer Name', 'Product', 'Quantity'] }
    SET Producttable TO { ^['Customer Code', 'Customer Name', 'Product', 'Quantity1', 'Quantity2', 'Quantity3', 'Quantity4'], [1234, 'John', 'Apple', 2, 3, 3, ''], [1234, 'John', 'Mango', 1, 0, 2, 0], [1234, 'John', 'Peach', 2, 2, 1, 0], [12345, 'Carl', 'Apple', 2, 1, 0, ''], [12345, 'Carl', 'Mango', 5, 3, 0, 0], [678, 'Ben', 'Peach', 1, 3, 4, 1], [678, 'Ben', 'Mango', 5, 3, 4, ''] }
    LOOP FOREACH CurrentProductItem IN Producttable
     LOOP LoopIndex FROM 1 TO 4 STEP 1
     IF IsNotEmpty(CurrentProductItem['Quantity' + LoopIndex]) THEN
     SET RowValue TO [CurrentProductItem['Customer Code'], CurrentProductItem['Customer Name'], CurrentProductItem['Product'], CurrentProductItem['Quantity' + LoopIndex]]
     Variables.AddRowToDataTable.AppendRowToDataTable DataTable: resultTable RowToAdd: RowValue
     END
     END
    END

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    I would always opt for a VBA macro for anything in Excel if you are open to using them.  For this particular use case:

    Save As new workbook (if you need to retain the old information)

    Insert a column before Qty 1

    Sum all numbers to the right

    Copy down the formula

    Copy Result column and paste values

    Delete all Quantity columns.

     

    Obviously, the VBA logic is more syntax than that, but GPT would make quick work of writing it.

     

    Good luck! 

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 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard