+ Reply to Thread
Results 1 to 5 of 5

Values from different columns lined up in one column, in pivot table?

  1. #1
    Registered User
    Join Date
    09-12-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    3

    Values from different columns lined up in one column, in pivot table?

    Hi there!

    I have a pretty large excel document lined up like this


    Name Age Weight Age Weight

    Charlie 35 75 36 77

    Cecilia 31 72 33 74

    Hannah 34 78 35 63

    Peter 32 63 34 85

    Fred 34 75 36 77

    Lucy 31 85 34 66

    Johnny 32 92 36 95

    Tony 35 102 36 102


    The weight is on the right side of the corresponding age.

    I'd like to have all the weights lined up based on *** and age, like:


    Men

    Age: 31 32 33 34 35 36

    Weight: 63 75 75 77

    92 85 102 77

    95

    102

    Female


    Age: 31 32 33 34 35 36

    Weight: 72 74 78 63

    85 66






    How should I do this, with INDEX/VLOOKUP or a Pivot table? Any ideas are highly appreciated!

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Values from different columns lined up in one column, in pivot table?

    Do you have a column that specifies gender?

  3. #3
    Registered User
    Join Date
    09-12-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Values from different columns lined up in one column, in pivot table?

    Quote Originally Posted by daffodil11 View Post
    Do you have a column that specifies gender?
    Sorry for not pointing that out but yes, I do.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Values from different columns lined up in one column, in pivot table?

    Seems doable. Are there more than 2 sets of age and weight? Can you provide a sample with at least 10 rows? Can you tell me how many rows there actually is?

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Values from different columns lined up in one column, in pivot table?

    First I'd use a series of VLOOKUP, COUNTIF, MATCH, and INDEX to reorganize the data into 4 columns for easier manipulation first. (doing it by hand would be a pain)

    Assuming your example data puts Tony in A9, in A10 I go with =IF(COUNTIF($A$2:A9,A2)<COUNTIF($C$1:$Z$1,"Age"),A2,"") and copy downwards.

    This will repeat the names for as many times as another age occurs.

    B10: =IFERROR(VLOOKUP(A10,$A$2:$B$9,2,0),""), and matches the Gender to the name.

    C10: =IFERROR(INDEX($C$2:$H$9,MATCH($A10,$A$2:$A$9,0),(COUNTIF($A$2:$A10,$A10)*2)-2+COLUMN(A1)),"")

    D10: =IFERROR(INDEX($C$2:$H$9,MATCH($A10,$A$2:$A$9,0),(COUNTIF($A$2:$A10,$A10)*2)-2+COLUMN(B1)),"")

    I copy A10:D10 down as far as needed.

    The somewhere off to the side, in AA2, I rank the ages.

    AA2: =IF(OR(B2="M",B2="F"),COUNTIF($B$2:$B$50,B2)-((SUMPRODUCT(($B$2:$B$50=B2)*($C$2:$C$50<C2))+1)+COUNTIFS($C$2:C2,C2,$B$2:$B2,B2)-1)+1,"")

    Entered as array using Ctrl+Shift+Enter to confirm, instead of normal Enter.




    Lastly, we pull the data with index and match, using the Ranks as markers.

    On the second tab, I put Men in A1, Age in A2, Weight in A3

    B1: =COUNTIF(Sheet1!$B$2:$B$500,"M")

    C1: =IFERROR(IF(B1-1<1,"",B1-1),""), and then copy it right a bunch

    B2: =INDEX(Sheet1!$C$2:$D$25,MATCH(1,(B$1=Sheet1!$AA$2:$AA$25)*("M"=Sheet1!$B$2:$B$25),0),ROW(A1))

    This is another array formula.

    B3: drag formula from B2 into B3, copy as far over as needed.



    For women, repeat as above, changing M to F and changing =INDEX(Sheet1!$C$2:$D$25,MATCH(1,(B$1[=Sheet1!$AA$2:$AA$25)*([b]"F"[b]=Sheet1!$B$2:$B$25),0),ROW(A1)) to match whatever row you put the women's ranks in.

    data fun.xlsx
    Last edited by daffodil11; 09-12-2013 at 03:16 PM. Reason: Index(match changed to match(1/

+ 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. Replies: 11
    Last Post: 07-18-2013, 05:14 PM
  2. Pivot Table based on specific values from multiple columns
    By Jaypoc in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-22-2013, 12:33 PM
  3. Pivot Table, Counting Same Values Across Multiple Columns
    By livifivil in forum Excel General
    Replies: 1
    Last Post: 09-12-2012, 01:46 AM
  4. Replies: 0
    Last Post: 01-29-2010, 06:40 PM
  5. Replies: 2
    Last Post: 07-14-2006, 08:30 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