Use cell value for file name in excel formula - excel

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.

Related

How to copy a data row from column A to column B, between each data row

Troubles with the update formula Troubles with formula, asking for a missing matrix Steps, I have tried to retrieve data from column B to column D
Know is telling that I insert insufficient argumentsGood afternoon,
I have column B, with descriptions in Portuguese, row by row and column D with the translations in English:
I'm trying to insert in column D the corresponding translation in Portuguese under each data row in English.
But I can't find any formula to do that, also I didn't find any question like this in the forum.
The only nearest question about, is to insert a blank row between data rows with this formula =MOD(ROW(D2),2)=0 or with a filter adding series. And retrieving data with vlookup, as in the attached image.
You can use power query to tackle this task.
I have used the following data for demonstration. Please note I am using Excel 365 English version.
| Portuguese | English |
|------------|---------|
| um | one |
| dois | two |
| trĂªs | three |
| quatro | four |
| cinco | five |
| seis | six |
| Sete | seven |
| oito | eight |
| nove | nine |
| dez | ten |
Steps are:
Load/Add the data set to Power Query Editor;
Make a duplicated column of Portuguese, then add an Index column with index starting from 1, then you should have something like below:
Use Merge Columns function under Transform tab to merge the English column with the Portuguese - Copy column with a custom delimiter such as hashtag # (as long as this delimiter is not part of your original texts), then you should have:
Use Split Columns function under Transform tab to split the merged column by the same delimiter #, and make sure in the Advanced Settings to choose to put the results into Rows as shown below:
The output will look like the following:
You can choose to remove the Portuguese column if you do not want to show it in the final output, then Close & Load the table to a new worksheet (by default).
Here are the power query M Codes behind the scene. All functions used are within GUI so should be easy to follow and execute.
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Portuguese", type text}, {"English", type text}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Portuguese", "Portuguese - Copy"),
#"Added Index" = Table.AddIndexColumn(#"Duplicated Column", "Index", 1, 1),
#"Merged Columns" = Table.CombineColumns(#"Added Index",{"English", "Portuguese - Copy"},Combiner.CombineTextByDelimiter("#", QuoteStyle.None),"Merged"),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Merged Columns", {{"Merged", Splitter.SplitTextByDelimiter("#", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Merged"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Merged", type text}})
in
#"Changed Type1"
Let me know if you have any questions. Cheers :)
Put this formula in the Result Column and adjust $A$1 to your first portuguese term and $B$1 to you first translated term:
'=OFFSET($A$1;((ROW()-ROW($B$1))/2)-ROW($A$1)+1;0)
You should get a Column, where every Portuguese term is repeated. Now you can overwrite the formulas in the upper cells with the english translations.
The formula calculates the difference between current (translated row) cell and the first translated row and cuts it in half: that is the row of the portuguese term to associate with this cell. Then it uses that row number as offset to the first row of portuguese terms.
Now, if you want to have the forst row empty, you can of course fill the whole formula in the true part of an if formula:
=IF(MOD(ROW()-ROW($B$1),2)=0;"";OFFSET($A$1;((ROW()-ROW($B$1))/2)-ROW($A$1)+1;0))
That is something you will often do in excel and I assume you know that trick. It makes the core formula a little harder to read, but it basically says: if the current row inside this block is divisible by two, then set the row empty, else set the row equal to the formula I presented above.

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.

How can I merge 2 spotfire tables by a regex match?

I am working on a spotfire tool, and I am using a calculated column in my main data table to group data rows into 'families' through a regex match. For example, one row might have a 'name' of ABC1234xyz, so it would be part of the ABC family because it contains the string 'ABC'. Another rows could be something like AQRST31x2af, and belong to the QRST family. The main point is that the 'family' is decided by matching a substring in the the name, but that substring could be any length, and isn't necessarily the beginning of the name string.
Right now I am doing this by a large nested If statement with a calculated column. However, this is tedious for adding new families, and maintaining the current list of families. What I would like to do is create a table with 2 columns, the string match and the family name. Then, I would like to match from this table to determine family instead of the nested if. So, it might look like the below tables:
Match Table:
id_string | family
----------------------
ABC | ABC
QRST | QRST
SUP | Super
Main Data Table:
name | data | family
---------------------------------------
ABC1234 | 1.02342 | ABC
ABC1215 | 1.23749 | ABC
AQRST31x2af | 1.04231 | QRST
BQRST32x2ac | 1.12312 | QRST
1903xSUP | 1.51231 | Super
1204xSUP | 1.68123 | Super
If you have any suggestions, I would appreciate it.
Thanks.
#wcase6- As far as I know, you cannot add columns from one table to another based on expression. When you add columns, the value in one matching column should exactly match with the other one.
Instead, you can try the below solution on your 'Main Data Table'.
Note: This solution is based on the scenarios posted. If there are more/different scenarios, you might have to tweak the custom expressions provided.
Step 1: Add a calculated column 'ID_string' which ignores lower case letters and digits.
Trim(RXReplace([Name],"[a-z0-9]","","g"))
Step 2: Add a calculated column 'family'.
If([ID_string]="SUP","Super",If(Len([ID_string])>3,right([ID_string],4),[ID_string]))
Final Output:
Hope this helps!
As #ksp585 mentioned, it doesn't seem like Spotfire can do exactly what I want, so I have come up with a solution using IronPython. Essentially, here is what I have done:
Created a table called FAMILIES, with the columns IDString and Family, which looks like this (using the same example strings above):
IDString | Family
------------------------
ABC | ABC
SUP | Super
QRST | QRST
Created a table called NAMES, as a pivot off of my main data table, with the only column being NAME. This just creates a list of unique names (since the data table has many rows for each name):
NAME
------------------------
ABC1234
ABC1215
AQRST31x2af
BQRST32x2ac
...
Created a Text Area with a button labeled Match Families, which calls an IronPython script. That script reads the NAMES table, and the FAMILIES table, compares each name to the IDString column with a regex, and associates each name with a family from the results. Any names that don't match a single IDString get the family name 'Other'. Then, it generates a new table called NAME_FAMILY_MAP, with the columns NAME and FAMILY.
With this new table, I can then add a column back to the original data table using a left outer join from NAME_FAMILY_MAP, matching on NAME. Because NAME_FAMILY_MAP is not directly linked to the NAMES table (generated by a button press), it does not create a circular dependency.
I can then add families to the FAMILIES table using another script, or by just replacing the FAMILIES table with an updated list. It's slightly more tedious than what I was hoping, but it works, so I'm happy.

Transfer Excel Pivot table to Access

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.

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:

Resources