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 / 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,656 Super User 2025 Season 2 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,250 Super User 2025 Season 2 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

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard