+ Reply to Thread
Results 1 to 7 of 7

Shifting Values for Several Columns

  1. #1
    Registered User
    Join Date
    11-21-2020
    Location
    Toronto
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Shifting Values for Several Columns

    Hi everyone,

    I have a large dataset where I need to shift up the values of several columns for the same ID, as in the attached spreadsheet. The table at the top is the format of my original data; I need to bring it in the format of the second table, at the bottom.

    Not sure yet how to approach it, or even if it's possible to do this with Excel formulas.

    Any pointers would be appreciated.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Shifting Values for Several Columns

    what is considered "previous Purchase"?

  3. #3
    Registered User
    Join Date
    11-21-2020
    Location
    Toronto
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Shifting Values for Several Columns

    Hi, previous purchase is a purchase made on the date previous to the current date.

    So my task is to shift the values of cells G3, H3, I3, and J3 up on the same row as G2, H2, H2, and J2.

    In this context, G2, H2, H2, and J2 are "current" items, namely from the most recent date. G3, H3, I3, and J3 become "previous" purchase, description, label, and price, as I am shifting them up on the same row of the most recent date.

    And so on, G4, H4, I4, and J4 get shifted up on the same row with G3, H3, I3, and J3, etc., until there are no more records for the respective ID.

    Then the same process for the next ID.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,005

    Re: Shifting Values for Several Columns

    2 Helper columns

    In K2

    =IF(COUNTIF($A$2:$A2,$A2)=COUNTIF($A$2:$A$10,$A2),"",MAX($K$1:$K1)+1)

    in L2

    =IF(COUNTIF($A$2:$A2,$A2)=1,"",MAX($L$1:$L1)+1)

    in A15

    =INDEX(A$2:A$10,AGGREGATE(15,6,ROW($A$2:$A$10)-1/($K$2:$K$10<>""),ROWS($1:1)))

    copy down and across to J

    in K15

    =INDEX(G$2:G$10,AGGREGATE(15,6,ROW($A$2:$A$10)-1/($L$2:$L$10<>""),ROWS($1:1)))

    Copy across to N and down
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-21-2020
    Location
    Toronto
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Shifting Values for Several Columns

    John Topley, the solution you suggested works!

    Thanks very much.

  6. #6
    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
    79,369

    Re: Shifting Values for Several Columns

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

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon 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 those who helped.
    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.

  7. #7
    Registered User
    Join Date
    11-21-2020
    Location
    Toronto
    MS-Off Ver
    Microsoft 365
    Posts
    9

    Re: Shifting Values for Several Columns

    AliGW, thanks for the suggestions! Done.

+ 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. [SOLVED] Formula needed for shifting values between columns. How can I achieve this?
    By sonnyjim1889 in forum Excel General
    Replies: 3
    Last Post: 11-05-2019, 01:07 AM
  2. [SOLVED] Shifting columns using excel formula
    By nyambura in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-27-2017, 02:22 PM
  3. [SOLVED] Shifting columns in a workbook
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2014, 08:06 AM
  4. Shifting and combining columns using VBA
    By texas979 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2013, 03:02 AM
  5. [SOLVED] shifting columns
    By clc3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 12:00 PM
  6. [SOLVED] Deleting and shifting cells and columns
    By Curt1521 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-08-2006, 11:20 AM
  7. [SOLVED] Columns Shifting on Import of Data
    By Carroll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2005, 12:06 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