+ Reply to Thread
Results 1 to 10 of 10

Complex TRANSPOSE problem

  1. #1
    Registered User
    Join Date
    04-26-2024
    Location
    Netherlands
    MS-Off Ver
    O365
    Posts
    4

    Complex TRANSPOSE problem

    Hello,

    I am trying to transpose a table. The table consists of rows of items and columns showing the ordered quantity. The cells then show the unit price that is paid for each quantity. I want to transpose this table into a 3 column table with the item, quantity and price, omitting the blanks.

    Example table before:

    Item 1 2 3 4 5
    aaa 10 9 8
    bbb 15
    ccc 20 18 16 15 14
    ddd 10 8 6 5 4
    eee 30 25 22

    Desired result:

    Item Qty Price
    aaa 1 10
    aaa 2 9
    aaa 3 8
    bbb 1 15
    ccc 1 20
    ccc 2 18
    ccc 3 16
    ccc 4 15
    ccc 5 14
    ddd 1 10
    ddd 2 8
    ddd 3 6
    ddd 4 5
    ddd 5 4
    eee 1 30
    eee 2 25
    eee 3 22

    I know I can use the Excel function to transpose, but it's a lot of lines, so this is a no go. I can do this in VBA. But I prefer to do this in a formula, partly because it's dynamic. I am quite familiar with ARRAY and TRANSPOSE formula's, but I haven't figured this one out yet. Any ideas?

    Example report.xlsx
    Last edited by RubenvanHout; 04-26-2024 at 03:50 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Complex TRANSPOSE problem

    Welcome to the forum.

    TRANSPOSE on its own would not work with this data, anyway. But any formula may be slow with big data - how 'big' are we talking?

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Complex TRANSPOSE problem

    Hi
    this can be achieved using Power Query. You don't need to do anything, just download the attached file, add data if needed and click " Refresh all" (gemakkelijk gaat ook :-) )

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-26-2024
    Location
    Netherlands
    MS-Off Ver
    O365
    Posts
    4

    Re: Complex TRANSPOSE problem

    Thanks for the replies, I have attached an example workbook.
    There are about 350+ lines in this case, so too much to do manually, but formulas should easily handle it.

    I will check out the Power Query solution.

    I am still curious for the a solution using formulas, if only for improving my skills .

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Complex TRANSPOSE problem

    350 rows is nothing!

    Just looking at a formula solution. I've got it as far as two columns so far:

    =LET(t,TOCOL(SUBSTITUTE(B2:F6,"",0)),r,DROP(REDUCE("",A2:A6,LAMBDA(x,y,HSTACK(x,EXPAND(y,,COUNTIF(B1:F1,"<>"),y),""))),,1),HSTACK(TRANSPOSE(FILTER(r,r<>"")),t))

    Just got to add the count column and then filter out blanks.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-26-2024
    Location
    Netherlands
    MS-Off Ver
    O365
    Posts
    4

    Re: Complex TRANSPOSE problem

    The Power Query solution got the result I wanted.

    I will play with the formula to get the same result. It would have taken me at least a day to figure out something like that.

    Thanks a lot for your quick help!

  7. #7
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,013

    Re: Complex TRANSPOSE problem

    Another way,
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Complex TRANSPOSE problem

    This seems to work:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Complex TRANSPOSE problem

    You've marked this as solved.

    If you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  10. #10
    Registered User
    Join Date
    04-26-2024
    Location
    Netherlands
    MS-Off Ver
    O365
    Posts
    4

    Re: Complex TRANSPOSE problem

    Sure, handed out some rewards .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. table transpose complex
    By cane_pluto in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-04-2024, 11:43 PM
  2. Complex Transpose question
    By moga in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-27-2023, 12:26 PM
  3. [SOLVED] Transpose of complex(?) data
    By 1411 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-07-2021, 03:15 PM
  4. Complex Transpose
    By Sammysamface in forum Excel General
    Replies: 1
    Last Post: 05-26-2017, 01:10 PM
  5. Complex Transpose Help
    By pip74205 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-22-2015, 10:56 AM
  6. Complex transpose macro
    By kammariarun in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2013, 12:08 PM
  7. conditional transpose complex
    By susriram in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-30-2011, 01:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1