+ Reply to Thread
Results 1 to 12 of 12

Create panel data with multiple variables

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Create panel data with multiple variables

    in reference to this link: https://www.excelforum.com/excel-gen...-into-one.html
    i would like to ask how to create panel data if we have multiple variables in a sheet as:

    company 2006 2006 2006 2007 2007 2007 2008 2008 2008 2009 2009 2009 2010 2010 2010
    EPS ROE ROA EPS ROE ROA EPS ROE ROA EPS ROE ROA EPS ROE ROA

    PLEASE PROVIDE ANSWER, HELP ME IN DOING THIS AS
    COMPANY EPS ROE ROA
    X 2006
    X 2007
    X 2008
    X 2009
    X 2010
    Y 2006
    Y 2007
    Y 2008
    Y 2009
    Y 2010
    Z 2006
    Z 2007
    Z 2008
    Z 2009
    Z 2010

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    The formatting in the post is not very clear, so it would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Please note that the Paperclip icon does not work.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Re: Create panel data with multiple variables

    PFA file "my data"
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    I've attached a formula solution which is quite generic - if you were to add 3 new columns to Sheet1 for 2011 (and subsequent years), then it will automatically adjust. Here's the formulae I used in the Required sheet:

    A2: =INDEX(Sheet1!A:A,INT((ROWS($1:1)-1)/(COUNT(Sheet1!$1:$1)/3))+3)&""

    which returns the company names for as many times as you have years (block of 3 columns) in row 1 of Sheet1

    B2: =IF(A2="","",YEAR(INDEX(Sheet1!$1:$1,MOD(ROWS($1:1)-1,COUNT(Sheet1!$1:$1)/3)*3+2)))

    which returns the appropriate range of years for each company

    C2: =IF($A2="","",INDEX(Sheet1!$B$3:$P$22,MATCH($A2,Sheet1!$A$3:$A$22,0),MATCH(C$1,Sheet1!$B$2:$P$2,0)+(COUNTIF($A$2:$A2,$A2)-1)*3))

    which returns the appropriate value for the EPS amounts. This formula can be copied across into D2:E2 to return the P/E and P/B data.

    Note that in Sheet1 you had spaces after EPS, P/E and P/B, which I have removed. I have also applied a Custom Format to cells C2:E2 of General;-General;, in order to show blank values in Sheet1 as blanks.

    The formulae in A2:E2 can then be copied down as far as you need to - I've copied to row 105 in the example file.

    Hope this helps.

    Pete
    Attached Files Attached Files

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Create panel data with multiple variables

    Hi Pete and Shweta_ip,

    This problem was solved using Power Query. See the problem that teylyn created and was solved at:

    https://wessexbi.wordpress.com/2014/...h-power-query/

    You will need Power Query to do the steps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    Hi Marvin,

    I can't do that, as I'm using XL2007 (yes, cheapskate !!)

    Pete

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Create panel data with multiple variables

    Hey Pete,

    I loved your answer. The fact that teylyn couldn't do it either and needed help, shows it isn't an easy problem. I'm still trying to understand the links answer (and your answer also). I'm not sure it works on this problem. Good answer you gave above.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    Thanks for the rep, Marvin.

    Three formulae, and it's done - what's the problem ?

    Many of the 3's that appear in the formulae (i.e. /3 and *3) come about because that is the number of columns in each yearly block, so if there were more then the 3 can be changed as appropriate (or changed to a COUNTA expression). The +3 in the first formula relates to the first row where the data starts. Consequently, the solution could be made even more generic for other cross-tab reports.

    Pete

  9. #9
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Re: Create panel data with multiple variables

    Hi Pete

    Thank you so much, this is great help.

    I have data for years 2011-2016, and i tried to add these years and get the result but could not get the answer. PFA the sheet and guide me where am i wrong.
    Attached Files Attached Files

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Create panel data with multiple variables

    Hi Pete,

    The question is now, if your formulas are correct. I went back and used Power Query to do what my link above suggested. I get 175 rows of data while your answer gets just over 100 rows. Here is my Power Query answer. You should be able to look at the data without a newer version of Excel. Why are our answers different?

    PQ Unpivot double head transformed.xlsx

    (you might owe me my rep back .. grin)
    Last edited by MarvinP; 05-26-2017 at 01:46 AM.

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    Quote Originally Posted by MarvinP View Post
    ... Why are our answers different? ...
    Hi Marvin,

    Your data is laid out differently, by having a Marker column with EPS, P/E and P/B on each row, rather than showing them in different columns, so generally you would expect there to be 3 times the number of rows that I used. There are 5 years of data (2006 to 2010 inclusive) and 20 customers, so my solution needed 100 rows of data (plus header row). If you sort your Sheet3 by Company you can easily see what the difference is - your solution is not showing blanks, so 20 Microns Ltd., which sorts to the top, only has 6 rows instead of 15 rows which the next company, 3I Infotech Ltd., has.

    Looking at my solution, there are 42 blank rows, which would equate to 126 of your rows, so instead of you needing 300 rows, you only need (300-126 = 174) rows (plus the header row).

    Hope this helps.

    Pete

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,702

    Re: Create panel data with multiple variables

    Quote Originally Posted by shweta_ip View Post
    ... and guide me where am i wrong...
    There were two things that needed adjusting. I pointed out that your headings in row 2 of Sheet1 contained spaces, and I removed them in the earlier solution. This time I have left them in and just copied B2:D2 from Sheet1 into C1:E1 of the Desired sheet, so you now have matching headers.

    The other thing is that you had amended the formula in C2 to take account of the wider range, but you did not seem to have copied this across and down. Here is the formula:

    =IF($A2="","",INDEX(Sheet1!$B$3:$AH$995,MATCH($A2,Sheet1!$A$3:$A$995,0),MATCH(C$1,Sheet1!$B$2:$AH$2,0)+(COUNTIF($A$2:$A2,$A2)-1)*3))

    which I have now copied across and down to replace the other formulae.

    You have 993 companies and 11 years worth of data, so you will need to copy the formulae down 10923 rows for the complete solution.

    Hope this helps.

    Pete
    Attached Files Attached Files

+ 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. Multiple variables to create a list
    By Tarontagosh in forum Excel General
    Replies: 1
    Last Post: 05-03-2017, 08:50 AM
  2. [SOLVED] How to create percentages for a panel data?
    By occitania in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-16-2015, 03:42 PM
  3. Panel Data multiple selection
    By Mangus in forum Excel General
    Replies: 0
    Last Post: 09-09-2013, 11:19 AM
  4. Replies: 2
    Last Post: 08-22-2013, 11:57 AM
  5. Create three dimentional table based on panel data set
    By Terese Svensson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-10-2013, 04:10 PM
  6. long to wide transformation of panel data with many variables
    By mradzik79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2012, 02:44 PM
  7. how to create combination from multiple variables
    By chrismartinpetty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2010, 09:34 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