Excel 2010: Replace a table by an external connection without impacting other sheets - excel

I have a big workbook with a lot of data. In one sheet I have a table. This table is used for many Pivot tables used in other sheets, which are also used in other sheets.
The data for the table was copied manually regularly. I now have a external connection to import automatically the data but I'd like to avoid impacting other sheets.
How can I use my external connection without losing my table?
Thank you for your help

This might be a helpful workaround. I have successfully done this but it may require a bit of rework and not be the exact answer you expect. (I am using Excel 2010).
The reason for a workaround is I assume this is for a regular table (not a pivot table) as the source table. Unfortunately, I don't believe the switching connection options work for regular tables in Excel 2010.
Recreate a new table just below the other in the same worksheet by going to the Data tab > Get External Data > Existing Connections
Select your data connection (assuming it has been created) then select how you want to view the data. ie: Table
Place in your existing worksheet. Use your old table as a reference to reconnect all the connections to your other sheets, then delete the old table.
At this point, I find it easier to rebuild/copy those existing links to the new table with external data.
The good news: If your source table is a pivot table or pivot chart with an existing connection, you can easily change the table to have an external data connection (and switch between data connections).
For a pivot table with an existing connection you wish to change, select a cell in the table. In the ribbon above in 'PivotTable Tools' > Options tab > Change Data Source, you will be able to select this and reconnect to another source under 'Choose connection'.
For a pivot table with static data to introduce a new connection, I would suggest a similar workaround above.
I hope this works for you.

I'm going through this too. I've done some testing, and this is the approach I am going to take.
Save copy of file (just in case!)
Create a new sheet, and create link to your database, and have it entered as a table on this new sheet
Make sure your old table (manually entered) matches the same layout as the table with the data you are connecting to (same column order and column names)
For each pivot table, change the source to the new table (it should keep all of your setup the same if the columns are labeled the same)
Do a find and replace to change all formula referencing to the new table name.
Change any code in VBA that references the old tables
This should result in the least issues while making the changes. Just don't forget the first step!

If both connections/query are SQL or PostgreSQL, you can simply copy the query code from the new query to the old query. Then you do not even have to replace anything. "Edit" - "Advanced editor"

Related

Delete Power Query steps after loading to Power Pivot data model

I need to delete query steps after loading the data into model. The reason is to hide the sources, protect our know-how, or maybe I'm just not very proud of what I've done ;).
But when I delete PQ connections or change "Load To" option, also the tables disappear from data model and pivot table becomes unresponsive. It's also not possible to modify or delete the connection created in Power Query from Power Pivot window, or even view table properties.
I could use Review > Protect Workbook > Protect Structure to disable viewing and editing queries / connections, but the steps are still visible, and the user cannot modify the workbook; even pivot table drill-through function doesn't work as it needs to create a new sheet to show data rows.
If you need to remove the query steps, then you have to store the data within the Excel file (since a query is just a set of instructions for how to connect to the data and transform it).
What you can do is create a query, load it to a table in an Excel sheet and then delete the query, leaving a static table. You can then create a pivot table using this static table as the source and it should function normally (though you obviously won't be able to refresh the data). I.e. don't create a data model until you've loaded your data and removed the query.

Connecting different databases in Excel

Let's say I have an Access database, "ADB", and an Excel workbook, "EWB".
ADB has a table called "ATable" which contains columns including a column called "A_ID"
EWB has a worksheet called "EWorksheet" which contains columns "E_ID" and "ECol"
Now, I want to know how I can create an Excel worksheet that combines ATable.A_ID from ADB and EWorksheet.ECol from EWB, where if A_ID = E_ID then return ECol.
So in SQL, it should look something like this:
SELECT ATable.A_ID, EWorksheet.ECol
FROM ADB.ATable, EWB.EWorksheet
WHERE ATable.A_ID = EWorksheet.ECol
Of course I want the data to be dynamic, so that data will be updated when refreshed.
You need something called PowerQuery, in Excel 2016 comes by default. In previous versions you will have to install it.
Once you have it, it´s pretty straightforward. Select a connection as seen below selecting an Access database or an Excel workbook.
Once you have both queries loaded in PowerQuery you need to merge them through the column you specified, and that will make the join for you.
What PowerQuery does is record a set of steps such as connecting to an Access database or merging 2 tables. Those steps are saved within the file, so when you click RefreshAll in Excel it will reproduce those same steps you specified and bring you the latest data.

Change data source of a list table in Excel 2010

Is there a way to change the data source of a list table in Excel? It's easy to change the data source of a pivot table but the only way I have found to change the data source of a list table is to delete the table and start again.
Just to be clear, what I mean by a list table is what you get when you set up a connection to a table or query in Access (for example) and then click on "Existing Connections" under the Data tab.
I would prefer a method using the usual user interface but if there is a method that works only in VBA, that would be fine.
You can do it from the Excel interface without VBA.
Under the Data tab, click on Connections.
From the Workbook Connections dialog, click Properties.
From the Connection Properties dialog, click Definition.
Browse for a connection file and then select a table.
That's it.
If your data source is inside Excel on another sheet and you're using OLE DB Query, you might find changing the data source impossible (which was the case with me).
To change the data source in this instance, you need to click on Resize Table under the Table Design tab in Excel, as can be seen below:
When you click on this, you are able to change the range of your query, as can be seen below:

Link to pivot table from another excel file

Banging my head against the wall on this one and every option I try has a problem with what i am trying to achieve.
So I have a pivot table in excel that is connected to a database. What I want to be able to do is have a link in another excel sheet to that pivot table, so that it picks up any changes to it in terms of data. The reason I am doing this is because I am putting the excel file up on sharepoint, but if a user downloads it, it retains the connection to the SQL Database, and because they are not authenticated, it doesn't refresh. I need them to be able to do this because it will allow them to customise their pivot table as needed, and it will retain that when they next open it. But the original pivot table, connected to the datasource, won't be affected.
I have tried:
Copying Pivot Table: I have copied the pivot table and pasted it in a new excel file, and this retains the connection to the SQL Database so doesn't work.
Moving Worksheet: I have tried moving the whole worksheet to a new excel file and this does again retains the link to the SQL Database.
Creating connection to excel file: This connected to the excel file, but the pivot table is lost and it simply shows the data in standard excel format.
Slicers: I have looked at slicers but this won't work either, because it means if he makes a change it is reflected in the original pivot table.
Sharepoint: I have looked at excel services on sharepoint. Although I can get him to view the data on the online excel, again, if he downloads it it loses the connection.
I guess I could change the authentication settings on SQLServer so that rather than using windows authentication I create a password and then that password is retained as I copy the file. Because this would only allow access to the view in the SQL Database this would prevent any detrimental activity. However, what I would really like to do is just give a copy of the excel file that connects to the original pivot table (so that when this updates this data is reflected in the copy on refresh), but any changes in the copy (i.e. formatting etc) only affect the copy.
If anyone knows how to do this I would be most appreciative of your help.
I may said something incorrect here, so pardon my lack of knowledge, but with the option:
Creating connection to excel file: This connected to the excel file, but the pivot table is lost and it simply shows the data in
standard excel format.
If I understand correctly, Creating connection to excel file provides a copy of the database in an excel file with all the source data from the original pivottable, and if by "connected to the excel file" you mean that any changes to the original pivottable is updated in this connected file in the copy of the database.
Then adding a replica of the pivottable in this connected excel file pointing to the copy of the data would not solve the problem?
Am I missing something?

How do you copy the powerpivot data into the excel workbook as a table?

I have data in powerpivot that I've modified and I'd like to place it into the workbook as a regular table (and not as a pivottable). I need this so that I can run use the table for some vlookups from another worksheet in the same workbook.
I found this answer: link which I will try and summarize with out cutting and pasting to much. This assumes you have powerpivot installed.
goto powerpivot and "import from and external source" the data you want to munge and bring back into the workbook as a table
Key here is to select the checkbox “Enable selection of multiple tables”.
when prompted at the "import data" window, pick pivot report (you won't really use this)
go back to powerpivot with the "Manage Data Model:
add a new measure below your data. something like: NRofOrders:=COUNTROWS(values(FactResellerSales[SalesOrderNumber]))+0
(you won't really use this but this seems to change the query to this table so that you can use DAX)
also add any columns that you want ( for me, this is want I wanted that I wanted to be reflected back in the workbook)
back to Excel, select the data tab, click on Existing connections and select Tables: and then pick a table from your query.
boom, you're done
(the link continues on and you should read that as it's interesting but at this point you should have powerpivot query with your modification as a table in your workbook)
The July 2014 update to Power Query (pushed out at the end of Aug) simplifies the answer. With the new Power Query Update you can pull the data into the Data Model with out having to also copy it to the Works sheet.
goto powerquery and import the data you want to munge. Use the option to just add it to the Data Model.
go back to excel and then go to powerpivot with the "Manage Data Model" button.
munge your data (add columns, whatever)
back to Excel, select the data tab, click on Existing connections and select Tables: and then pick a table from your query.
boom, you're done
In the PowerPivot window you can select the table, or elements of it, and then copy (nornal right click or ctrl +c) and paste that into your spreadsheet.
This works for reasonable amounts of data but if you try and do it with thousands of rows you may find that excel objects and falls over, based on my experience.
Vlookups kind of defeat the purpose of PowerPivot :-)
Found a great solution over on Mr Excel
(http://www.mrexcel.com/forum/power-bi/637919-extracting-static-data-powerpivot-without-pivot-tables.html)
If you are trying to get a PowerPivot table into Excel, then you can simply query it. The easiest way to set that up is to first create any pivot table based on you PowerPivot data. Then double-click the measures area to drill-through. This creates a table with a connection to your PowerPivot model. Then edit the command text by going to: Data > Connections > Properties > Definition tab > Command Text.
Change it to something like
Code:
EVALUATE Table1

Resources