Transfer Excel Pivot table to Access - excel

I am currently working with a large set of data in excel, a pivot table of 35X42380. We needed to transfer this data into an access database, but doing this with a line by line macro was a nightmare, after 40 minutes of hanging I gave up.
I was wondering if there is a fast way to unpivot this table to transfer to Access.
the data resembles:
Zip | 80 | 81 | 82 |
00501 | 1.0040 | 0.8963 | 0.7707 |
00544 | 1.0040 | 0.8963 | 0.7707 |
01001 | 0.6721 | 0.6614 | 0.6342 |
01002 | 0.6721 | 0.6614 | 0.6342 |
the big issue i'm having is that the zip column is A3:42380, the 35 ids are AM2:BU2, and the pivot table is AM3:BU42380
What I would like is:
Product | Zip | Factor
80 | 00501 | 1.0040
Forgive me in advance for my terrible formatting.
Also, I cannot easily change the format of the table, so avoiding that would be a plus.
Thanks,
Jay

Pivot table is just grouped information that feeds from other data set. To find data set:
Click on pivot table
You will see pivot table tools in the ribbon
Click on Analyze and Change Data source.
In Data source you will find location of table or range:
This is your un-pivoted table
To export excel sheet in Access:
Click on external data
then select excel.
Select import the data into new table.
Select your workbook to import.

You could also double click on grand total in pivot table to un-pivot it, but if its not pivot table you can't un-pivot it.

Related

Use cell value for file name in excel formula

I am trying to create a formula that will reference a cell in another workbook in a different folder. The bit I'm getting stuck on is using a cell value in place of the file name.
='C:\Users\Damien\Documents\Personal\Coffee\Workcards\[UGAG003.xlsx]Checklist'!$B$4
In the code above, I want UWEG003 to be replaced with the value of cell B3 in the current workbook and return the value of cell $B$4 in UGAG003.xlsx. I want to use the cell reference because i need to autofill the whole column. Essentially what I am trying to get is;
='C:\Users\Damien\Documents\Personal\Coffee\Workcards\[ & $B3 & .xlsx]Checklist'!$B$4
That way I'll be able to just drag it down the whole column.
I hope I've worded that more clearly this time...
I appreciate the help.
I have tried this...
=INDIRECT("'C:\Users\Damien\Documents\Personal\Coffee\Workcards\[" & $B13 & ".xlsx]Checklist'!$B$4")
and it works (sort of). However, it only works if the document is open. How can I make it visible regardless of whether the document is open or not?
The INDIRECT() function won't work here, because:
I need it to be visible even if the other worksheet isn't open
If you are really sure that having the workbook name in a cell for reference is the best way to go - I'd suggest going with a parameter query.
I recommend using powerquery just like ttobe said. You have not shown much so I will not show much either but I will guess at what you have. Look at this for an example.
Your current sheet has a table with columns and one value in the column is "Hours Spent On Job". Turn this (all columns) data into a Table (ctrl + t). Under Data you will need to Get & Transform From Table/Range. This is one table you can load and close.
Go back to Get Data > From File now choose file you will need to do the same with [UWEG002.xlsx]Checklist'.
Next you will merge the tables together then expand the columns that you want in power query.
I don't think you will be able to achieve what you want with Excel, because, as you said, the workbook you're trying to access the information from is not open. The easiest way is probably Power Query.
Since you did not post a sample data set, I made one up.
Table 1 (contained in a file I called Book2.xlsx):
+---------+
| MyData1 |
+---------+
| 1000 |
| 1005 |
| 1010 |
| 1015 |
| 1020 |
| 1025 |
| 1030 |
| 1035 |
| 1040 |
| 1045 |
| 1050 |
| 1055 |
| 1060 |
| 1065 |
+---------+
Table 2 (contained in a file I called Book1.xlsx):
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+---+
The goal is to pull the value of "4" into a second column in Book2.xlsx.
For this, I navigated to the "Data" tab in Book1.xlsx and pulled the table into Power Query as a connection only. I called the query "Book1". (In Excel, go to Data > Get Data > From File, then navigate to the file you want to access.)
I then pulled in the data from Book2.xlsx. When you do this with data that has a header and you mark it as such, Excel automatically converts your range to a table object. Here it's called "Table1", and I left it at that for the query name.
As a last step, I added a custom column as follows in the Table1 query:
= Book1[Column1]{3}
The {3} is the zero-based position of the value that you want from the other query.
The result is a column that automatically fills each row with the value you specified from the other file, and it does it without the issues you were experiencing due to the other file not being open.
This is the M code for the Book1 query:
let
Source = Excel.Workbook(File.Contents("PATHTOFILE\Book1.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", Int64.Type}})
in
#"Changed Type"
Here is the M code for the Table1 query:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"MyData1", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "FromBook1", each Book1[Column1]{3})
in
#"Added Custom"
A caveat: the path to the first file (the one you want to extract the information from) is hard-coded into the M code, which can cause issues if the file is later moved. There are work-arounds for this, but that goes beyond of the scope of your question.
The result:
I have encountered this problem.
Your B4 cell of Excel maybe contains the unrealized functions of the poi.
you must register the excel of function in your project first. you can use it.
Maybe this website can help you : code and register function
Simply use powerquery as mentioned above.
Establish a connection tothe 2nd workbook
"C:\Users\Damien\Documents\Personal\Coffee\Workcards[UGAG003.xlsx]"
Reference the "Checklist" as the data source, and load the data from it to where you desire, e.g. a new sheet in the 1st workbook.
Then simply use lookup, or directly reference the "loaded" data columns.
Data as from 2nd closed workbook
Each time you need to refresh, just hit refresh on the query.

PowerPivot One to Many Value

I have two tables.
An Issue table
+----+-------+
| ID | Name |
+----+-------+
| 1 | task1 |
| 2 | task2 |
| 3 | task3 |
+----+-------+
And table that extends issue by custom fields
+----+---------+------------+------------+
| ID | issueId | customName | val |
+----+---------+------------+------------+
| 1 | 1 | age | 22 |
| 2 | 1 | speed | 56kmph |
| 3 | 1 | startDate | 03.03.2015 |
+----+---------+------------+------------+
Problem in PowerPivot is that, when I select Issue as a Row, customField as Columns and val as a Value at place of Value Excel automatically aggregate using "Count of Value" which shows fields count, and for speed, startDate etc. excel shows "1", not the propper val of it.
Is it possible to force powerPivot to show value by its column name?
If you don't mind using Power Query, you can get to this fairly easily:
Here's how:
1. Add your tables as sources in Power Query. In Excel 2016, you can do that by clicking on a table, then on Data -> From Table. This will open Power Query with your selected table loaded. The table will be listed under Queries, on the left side of the screen.
Once you've loaded your first table as a source. Probably the simplest way to add the next one (by way of explanation anyhow) is to click File -> Close and Load, and do what you did previously, this time for the second source.
(When you Close and Load, a new tab will be created in your workbook, with the results of the new Query...which right now would just look like a duplicate of your original source table.)
2. Merge (join) your two queries.
a. Click on your Issues query, in the queries list on the left side of your screen. That will open the Issues query.
b. Click Home -> Merge Queries (drop-down) -> Merge Queries as New.
c. Fill in the dialog window like below and click OK. Make sure to select the columns you want to match on--highlighted in green here. This will create a new query, most likely named Merge. (Of course, you would use the names of your tables, instead of Issues and Extended.)
Your new query will look something like this:
d. Click on the button to expand the tables in the column of tables and make selections, like these, from the drop-down window and click OK.
You'll get a table something like this:
3. Pivot your customName column.
a. You can't pivot a column with nulls, so select the customName column, then Transform -> Replace Values, and enter these settings in the dialog window that pops up, then click OK (the Replace With box is left empty):
b. Select the customName column then Transform -> Pivot Column. Fill in the dialog window that pops up like this, below, and click OK.
4. Clean up. Select all the columns you want to keep, then click Home -> Remove Columns (drop-down) -> Remove Other Columns:
You'll end up with something like this:
When you Close and Load, you'll get a new tab with the final table in it.

Excel: how to group and then sort groups in a custom order?

I have a table of data, I want to group this data and then sort the groups of rows in a custom way.
Example:
I have a table of data like this:
key | group
-------------
BC.AA | BC
AA.AA | AA
CC.DE | CC
AA.CD | AA
And a list of groups like this
group | no. of items
-------------------
BC | 1
CC | 1
AA | 2
How do I create a new table where the rows of the first table are grouped and ordered in the same way the second table is ordered. So like this:
key | group
-------------
BC.AA | BC
CC.DE | CC
AA.CD | AA
AA.AA | AA
I like to do this with excel formulas, so it updates automatically when the original table is changed. I hope to avoid using macros, but I could write a custom excel worksheet formula.
You could add a column to your first table of =MATCH(B1, GroupSheet!A:A), which will just return the corresponding row in GroupSheet that matches your group column, and sort by that.
You can do this in Excel 2010 by selecting the data you want to sort, going to the Data tab, clicking the Sort icon and then choosing Custom List... under Order. This will be fine for small sorts, but you might need something more powerful for longer lists...

Recreating a non-straightforward Excel 'vlookup'

I'm looking for some thoughts on how you might recreate a 'vlookup' that I currently do in excel.
I have two tables: Data contains a list of datetime values; DateConverter; contains a list of calendar dates and their associated "network dates." Imagine for a business - not every day is a workday, so if I want to calculate differences in dates, I'm most interested in the number of work days that elapsed between my two dates.
Here is what the data might look like:
Data Table DateConverter Table
================= ===================
| Datetime | | Calendar date | Netowrk date |
| ------------- | | ------------- | ------------ |
| 6-1-15 8:00a | | 6-1-15 | 1000 |
| 6-2-15 1:00p | | 6-2-15 | 1001 |
| 6-3-15 7:00a | | 6-3-15 | 1002 |
| 6-10-15 3:00p | | 6-4-15 | 1003 |
| 6-15-15 1:00p | | 6-5-15 | 1004 |
| 6-12-15 2:00a | | 6-8-15 | 1005 | // Skips the weekend
| ... | | ... | ... |
In excel, I can easily map in the network date for each date in the Datetime field with a variant of vlookup:
// Assume that Datetime values are in Column A, Calendar date values in
// Column C, Network date values in Column D - this formula fills Column B
// Headers are in row 1 - first values are in row 2
B2=OFFSET($D$1,COUNTIFS($C:$C,"<"&A2),)
The formula counts the dates that are less than the lookup value (using countifs because the values in the search array are dates, and the search value is datetime) and returns the associate network date.
Is there a way to do this in Tableau? Will it require a calculated field or can I do this with some kind of join?
Thanks in advance for the help! Let me know if there is anything I can clarify. Thanks!
If the tables are on the same data server, you have the option to use joins, which is usually the most efficient way to combine information from different tables. If the tables are on different servers or platforms, then you can't use a single query to join them.
In either case, you can use Tableau data blending, which is sort of like a client-side join of aggregated results from multiple queries. Its a pretty useful technique, but a little more complex and restricted and also usually less efficient than a server side join.
So if you have the option to have both tables on the same server, start with that. It will be simpler and likely faster.
Note if you are going to use a date as a join key, you probably want to define it is a date and not a datetime.
#alex-blakemore's response would normally be adequate, but if you can change the schema, you could simply add the network date to the DataTable. The hourly granularity should not cause excessive growth and you don't need to navigate the joining.
Then, instead of counting rows and requiring a sorted table, simply subtract the Network date from each other and add 1.

Map Chart works in Power Map but does not work in the Power View Map

I am building a simple map report using Excel 2013 with Power Map and Power View. I struggle to understand why the same data are displayed correctly in Power Map; however, fails to display anything in Power View (either from the Excel range or Power Pivot).
Please can anyone give me heads up what I am missing?
Sample Data:
+----------+-------------+--------------+---------+--------------+
| Customer | Latitude | Longitude | Country | Constituency |
+----------+-------------+--------------+---------+--------------+
| 6394 | 53.97046592 | -1.080241735 | England | York Outer |
| 5643 | 53.95796996 | -1.091323488 | England | York Central |
+----------+-------------+--------------+---------+--------------+
I was able to make a Power View map with your data. I put a count of the Customer field as my size, Constituency as my location, and then used the longitude and latitude fields. It worked for me using the Range or adding the data to a Power Pivot model.
A couple of tips:
Put Constituency in the locations field so you can see the 2 points.
In Power Pivot, on the Advanced tab, set the data category to Latitude or Longitude for the appropriate field and it will always recognize it as geography.

Resources