+ Reply to Thread
Results 1 to 16 of 16

Line up values from one column based on value from another column

  1. #1
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Line up values from one column based on value from another column

    I have a data table of size 40'000 X 2:
    - Column A has 8'000 unique values.
    - Column B has 30'000 unique values.

    So, on average, every unique value in column A has 5 values of column B. In reality it varies from 2 to up to 10 values.

    I need this table to be resorted in such a way that it would end up being 8000 rows and 1+10 columns listing unique values from column A and lining up corresponding values from column B.

    Example:

    Sample.PNG

    I've been trying to use these:
    E2{=INDEX($A$2:$A$17, MATCH(0, COUNTIF($E$1:$E1,$A$2:$A$17), 0))}
    F2{=IFERROR(INDEX($B$2:$B$17, MATCH(0, COUNTIF($E2:E2,$B$2:$B$17)+IF($A$2:$A$17<>$E2, 1, 0), 0)), "")}

    It works, however, in the last 24 hours somehow I managed to get only 1000 rows finished. I played with manual and auto calculation, that doesn't help and Excel is either stuck at Calculating (8 threads): 0%, turns off automatically or just stops calculating.

    Any ideas on how to improve these functions or replace them with something else that would allow Excel to do these calculations much faster would be very welcomed.
    Attached Files Attached Files
    Last edited by Paulius03; 04-11-2020 at 06:08 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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    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
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Re: Line up values from one column based on value from another column

    Sample file

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Load your data into PowerQuery (Data ribbon | Form Table/Range ...).

    Use this M Code in the Advanced Editor window:

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

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Using your data - attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Re: Line up values from one column based on value from another column

    Hi AliGW,

    It works partially in my original excel. Now it brings only values that are numbers. I didn't mention before, by some of data in Clusters and Components have data like "10001A", "10001-100", "ABC10001".

  7. #7
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Well, you should have mentioned it!!! Inadequate sample data will always lead to inappropriate solutions.

    Provide an updated sample and I will have another look if I have time.

  8. #8
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Re: Line up values from one column based on value from another column

    Here it is
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Here's a version that should work for you. I had to remove the Changed Type step.
    Attached Files Attached Files

  10. #10
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    Administrative Note:

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.

  11. #11
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Re: Line up values from one column based on value from another column

    Thanks a lot AliGW. That's a totally unfamiliar part of Excel to me. Helped me a lot, thanks again.

  12. #12
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,426

    Re: Line up values from one column based on value from another column

    No worries. You can refresh the query using Refresh on the Data ribbon, or set it to refresh automatically.

    Please see post #10 and update your profile accordingly.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  13. #13
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Line up values from one column based on value from another column

    macro - press green button - no need for on sheet formula
    Attached Files Attached Files

  14. #14
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Line up values from one column based on value from another column

    For Office 365 Please try

    E2
    =UNIQUE(A2:A17)

    F2:F6
    =TRANSPOSE(FILTER($B$2:$B$17,$A$2:$A$17=E2))
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    04-11-2020
    Location
    Europe
    MS-Off Ver
    365
    Posts
    30

    Re: Line up values from one column based on value from another column

    Quote Originally Posted by Bo_Ry View Post
    For Office 365 Please try

    E2
    =UNIQUE(A2:A17)

    F2:F6
    =TRANSPOSE(FILTER($B$2:$B$17,$A$2:$A$17=E2))
    I don't seem to have UNIQUE function in my excel. Is it taken from some kind of library?

  16. #16
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Line up values from one column based on value from another column

    Unique Function is available if you update office 365.

    https://support.office.com/en-us/art...a-40204fb85e1e

+ 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. VBA - Creating new column (Columns M) with values based on previous column (Column L)
    By will12321 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2020, 03:36 AM
  2. Replies: 7
    Last Post: 10-23-2018, 10:18 AM
  3. [SOLVED] Sum values in Column A, based on dates in Column B & if value in Column C = True
    By rtcwlomax in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-25-2016, 12:03 PM
  4. Replies: 3
    Last Post: 03-22-2014, 08:35 AM
  5. Replies: 1
    Last Post: 03-10-2014, 04:09 PM
  6. Replies: 2
    Last Post: 06-06-2013, 08:29 AM
  7. Combining multiple line items into one line item based on column.
    By mguz018 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2012, 07:22 PM

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