Delete Power Query steps after loading to Power Pivot data model - excel

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.

Related

How can I write back to source excel files when I get Excel data from data tab?

So, I want to create one Excel file each for every manager with only one single sheet and place it on OneDrive.
In order to get the data in one place, I am creating another excel file called combined.xlsx.
Now, I can export each workbook to a tab using Data -> Get Data -> From File -> From Workbook .
This is great so far. So, I can read data of 10 excelfiles on 10 sheets in combined.xlsx.
Now, I want to modify contents of one of the tabs and make sure it is reflected to the original file. How can I do this?
To elaborate on why it is not possible, you need to understand how Power Query deals with data:
You load your data into Power Query via the "Data" tab. The source can be anything Microsoft allows.
You then manipulate the data any which way in Power Query.
As a last step, you decide if and where to load the results. If you only want to create a connection to the query, you select "Close and Load to", which appears after you click on the arrow next to "Close and Load", and you pick that. Otherwise, the only other options are loading the query results to a table, PivotTable report, PivotChart.
Because the output sheets you have are connected to the query that produced them, any time you refresh the query, whatever manual changes you have made in the table that the query created originally will be wiped out and overwritten with the refreshed data.
If you were able to write back to the source here, you'd in effect
create a circular reference.
Check out this article about having Power Query output your data after manipulating it, maybe it helps.

Save a pivot table structure based on external source without saving/cacheing the data

I have an external data source that implements row-level security.
I have an XLSX file which I want to distribute which will have a pivot table based on the external source. All of my users have an identically configured ODBC connection, except it uses each of their personal credentials and thus they have access to different data.
I've explored all of the connection & pivot table settings that supposedly give you such controls but they are not working for me. When I save my workbook, it seems that it is not possible to prevent the contents of the pivot table (as they currently look) from being saved. When a new user opens it, they will be able to see the current pivot table contents (which they perhaps shouldn't have access to) until they click "enable content", accept the various popups and/or wait for refresh.
Previously, I created a table based on external source and configured the connection to not save data - this worked. I then created a pivot table on top of the table range and configured it to not save source data. This sort of works except the table refreshes first and so the pivot table loses its settings and you have to start again with a blank pivot.
If you create a pivot table directly on the external source (rather than indirectly via a table), which I expect is the best practice, the tickbox in pivot table options for "Save source data with file" is greyed - presumably because excel knows the source data is actually external and so the question isn't relevant - except is is relevant because the pivot table output still contains data when saved
The only thing I can think of is is save the workbook as a user with 0 permission so the pivot table is structured correctly but with 0 contents and then send that round. Users will then see no/harmless data before it auto-refreshes at which point, they'll see what they should see.
Kind of feels like a glaring omission from excel. Am I missing something?

Cannot delete "ghost" table from Power Pivot

I have created many power queries and power pivot tables in my Excel file. After some time, I think the data structure may have gotten corrupted, because this is happening:
In Data Model, I have this Community_Membership table that cannot be deleted. It is the only table that has this behavior (all other tables were deleted successfully)
After that, I went to Power Query to delete all existing queries AND CONNECTIONS, so that the list is empty like below.
But this table remains un-deletable there after I have deleted all queries from queries list.
Anybody know how to fix this?
I finally recreated the file as follows:
Make a new Excel file
Copy all of the sheets
Select all of the queries from the old file's query pane, hit copy
Go to the new file's queries pane, hit paste
Go into Query Editor and edit any names with conflicts or remove any redundant queries
The entire process takes about 10 minutes as I only had about 10 queries / sheets.
I suspect this happened because I created a query, added it to the data model then went back to Power Query and edit it (either its name or its content in some mysterious way). After that the link between PQ and PP is broken so that even after the original query is deleted, its clone in PP remains. Strange.
I encountered a similar situation after having renamed a query in Power Query : Power Pivot could see the new table under the new name, but the old table was still there in Power Pivot and could not be deleted.
Finally I came up with this solution :
Make sure there are no remaining relationships or measures in Power Pivot that refer to the table you want to delete.
Create a query in Power Query, having the same name as the table you want to delete. The content of the query does not matter. Make sure that the checkbox "load into the datamodel" is checked. As a result, the synchronization between Power Pivot and Power Query is restored.
Edit the query again and uncheck the checkbox. Now Power Pivot understands that we want to remove that table.
Now you can delete the query in Power Query.

How to take data from PivotTable cache?

I have lost the connection to source analytics service. However, I still have data in PivotTable's cache (I can see from tooltips).
How to get that source data?
I am using Office365
** I cannot use show details since the pivot table has some filteres applied. And i cannot remove filters since it asks me to connect source.
(And yes I have checked this thread but it didn't work for me: Recreate Source Data from PivotTable Cache. It gives 1004 error.)
The easiest way I can think of for a table based data set is:
Show the field list on your pivot table.
Remove all filters, column labels, row labels, and values
Add one field to the values. This will show one aggregate value in the pivot table.
Double click the value and a sheet with all the data should pop up.
If it doesn't, go to the pivot table options then on the data tab check "Enable show details".
This method however will not work with OLAP data. Excel does not download the entire cube; it queries for new data slices with every change to the filters or layout of the pivot table/chart. So even if you could access the data in the pivot cache it would not hold the entire cube, but only the slices needed to show the current layout. You CAN create a snapshot cube file to hold all of the data needed to run in offline mode, however it requires you to be able to connect to the server at least once to create the file.

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

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"

Resources