Forum Discussion
Transposing problem
- Apr 12, 2018
Hi Jur,
That could be done with Power Query (aka Get&Transform). Convert source to the Excel table, with one query form left side with chronological data, another query for static one, append second to first and generate final table.
Please see attached. That's done without cosmetic, consider as prototype.
Thanks for your reply, I have a more precise description of the problem now and I am curious if this works for this particular problem as well:
Hello everybody,
I am having problems transposing data in Excel. I have a large dataset of around 2000 mutual funds, for these funds I have cross sectional data and time series data for four different variables: Returns, concentration, active share and fund size.
Per row there is one fund with all the accompanying data in the columns right from that cell for all the time series data and other variables.
The problem here is that I cannot find a solution for how to transpose the dataset to a panel format. In the attachment you find an example of the data for three mutual funds and what the desired sollution is to the problem.
That is the best way I can describe it to you I figured.
Thanks in advance,
All pointers/tips/tricks are very welcome!
Hoekstraat
Hi Jur,
That could be done with Power Query (aka Get&Transform). Convert source to the Excel table, with one query form left side with chronological data, another query for static one, append second to first and generate final table.
Please see attached. That's done without cosmetic, consider as prototype.
- DeletedApr 12, 2018The example you send with the reply is exactly what I mean, thank you so much.
Can you maybe be more specific in which steps you took to get to this final result?
If you have a step by step walk-through I can apply this to the full dataset.
Thanks in advance- SergeiBaklanApr 13, 2018Diamond Contributor
Now land results into the excel sheet. Open right pane and right click on first query name, select Load to, here is Table and location where you'd like to keep it
Right click on any cell within the table and select External table properties
within it deselect Adjust column width.
Now you may add bit cosmetic to your table - change design and format of columns / headers.
With changing of source data click Refresh in right click menu of the table or in Data section of ribbon.
File with above steps is attached.
As a comment, resulting data is bit incorrect. You have
- !DIV/0 errors within the source data,
- repeating column names (e.g. Return 5-2012 and some else repeated two times). It shall be corrected in source (all names are to be unique) or processed additionally within the query.
- empty columns in the middle;
- perhaps something else
But that better test on copy of real data.
- DeletedApr 13, 2018
I am working on transposing the data right nog within get&transform, but when filtering in the query editor I do not have the ''advanced filter'' option that you mention. Is that just because of a later update?
Is there another option i could use maybe?
- SergeiBaklanApr 12, 2018Diamond Contributor
Let continue with static information. Open in Excel right pane with queries, right click on your first query and Duplicate. Rename it (let say on Static) and Close and Load to -> Only create connection.
Open it again on editing and remove all steps from the bottom one by one (click on cross at the left on step name) keeping Filtering Rows as the last available step
Stay on that step, expand formula bar and within it change manually every "Text.Start..." on "not Text.Start..." and every "or" on "and", click Enter after that.
Final formula shall be as
collapse formula bar.
Select Attribute column (second one) and pivot it with Value column without aggregation.
That's all with this query.
Now return back to the editing of first query. After you opened it when Home->Append Queries
and select second query to append
Now sort ascending Name column and after that sort ascending Date column
Close query editor and keep changes.
- SergeiBaklanApr 12, 2018Diamond Contributor
To continue with query editing in excel ribbon click on
in opened right pane right click on query name and select Edit. You are in query editor now. On the right you'll see two generated steps, delete second one
select all columns like in Excel (first column, Shift, last column) and in editor ribbon click on
and replace on null
Now select only first Name column and
Text filter second column only with records needed for the left part of your resulting table
Now we shall split text and dates in your second column. Let remove the text after the date first. Select column and do
and replace USD on nothing (don't forget the space before USD)
Select second column and split it
by right space
Most probably third column will automatically changed on Date type, you will see one more step
If not - select it and Home->Data type->date.
Now select all columns and
After that select second column and drag it to the left on first position
Keep it selected and pivot
without aggregation on Value
Rename columns where necessary (double click on header and change the text).
That's all with this query, close the editor and save workbook.