PowerPivot One to Many Value - excel

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.

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.

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...

Nested filtering in Excel 2013 pivots

I have following table configuration in my Excel sheet (let's say that it's some kind of shop inventory):
Product | Type | Producer | Cost per unit
Apple | fruit | fruitCo | 5,00
Apple | fruit | bananaCo | 6,00
Banana | fruit | bananaCo | 4,00
T-shirt | clothes | clothsCo | 60,00
Etc.
And I've created a PivotTable from following data, that groups it by:
Filters: Producer, Type
Columns: Product
Rows: <empty>
Values: Sum of Cost
I've got two filters, Producer and Type. When I select a Producer from list (f.e bananaCo), the second filter shows me every kind of Type, even those that are not present in the already selected Producer filtering. Is there any way to make this filtering nested, so when I choose a Producer, only the types of product distributed by the selected producer appear in the Type filter list?
Not sure if this is the problem of not but try clicking on the Product field in the pivot and clicking the field settings button from the ribbon (under Options, Active Field) then Layout & Print in the window that appears.
Make sure Show items with no data is deselected.

Combining Columns in a Lotus Notes View

Is there an equivalent of GROUP BY statement in a Lotus Notes view?
Currently my table is laid out like this:
| JOB # | SHIP DATE 1 | MODULE 1 | SHIP DATE 2 | MODULE 2 |
| 111 | APRIL 2013 | 123-XYZ | APRIL 2013 | 654-ABC |
to this (/ stands for a twistie):
\/|SHIP DATES|
|MODULE 1|
|MODULE 2|
The final output would look something like:
\/|April 2013|
123-XYZ (this record would be from MODULE 1)
654-ABC (this record would be from MODULE 2)
\/|June 2013|
876-DEF (this record is from MODULE 1, since there is no ship date for MODULE 2 in this month/year only one job appears)
Is there any way I could merge the ship date columns together?
Categorization of views is the closest equivalent to "Group by" in a Notes view. So you're on the right track using a categorized view (i.e. the categories are the rows at the twistie level)
You should be able to achieve this using the setting "Show multiple values as separate entries" in your view. Set the Module column's formula to be
Module1:Module2
That means the value of that column is a multi-value list with two entries, the value of module1 and the value of module2.
For your categorized column formula, you should be able to use
#Unique(ShipDate1:ShipDate2);
to get the column to show the ship dates.
In the Ship Dates column you can "merge" the two fields by combining them with a colon. So if the two fields are called ShipDate1 and ShipDate2 the column formula is:
ShipDate1:ShipDate2
You also have to mark this property on the column:

Export records to excel sheet

I've got a table in access looking like this,
Category | Subcategory | Userdate (mm/dd/yyyy) | Color
I want to export this to an excel file where the Categories and Subcategories will be placed in column A and B respectively. However the Colors will be placed by month (Userdate), 12 months meaning Columns from C to N. So what I want to do is place the records from colors in different columns depending on the month (Userdate).
What is the best way to go about doing this? Create a recordset and loop through it? I reckon this will be a bit slow when rows exceed the 40k which is possible.
I could also make the table have Month columns like:
Category | Subcategory | January | February | etc...
So I could just export it just like that but seems to me that's just a bad way of making a table.
it sounds like you want a crosstab query:
TRANSFORM First(Table1.Colour) AS AColour
SELECT Table1.Category, Table1.Subcategory
FROM Table1
GROUP BY Table1.Category, Table1.Subcategory
PIVOT Format([Userdate],"mm-mmm");
You can transfer to Excel programmatically with DoCmd.TransferSpreadSheet

Resources