VLOOKUP with criterion in range - excel

I have a table A that contains ID (i.e. SR1000). Also a table B with two rows, another ID (i.e. C-1) and text on the second row.
I was trying to use VLOOKUP using the ID on table A to return ID on Table B if ID from Table A is somewhere in the text of column 2 in table B.
Table A
SR1000
SR1001
Table B
C-1|dummy text
C-2|dummy SR1000 dummy
So it should return C-2 when looking for SR1000.
Is VBA my only option? Trying to avoid reinventing the wheel.

It seems the formula:
=INDEX(F:F,MATCH("*"&B4&"*",G:G,0))
has been deemed fit for purpose and by way of explanation this was based on assumed locations as below:

Related

In power bi how to convert number to string

In my data table i have column category types (1, 2 , 3). I want to change them to say 1 = hot desk, 2 = fix desk, 3 = private company. how to do it? I'm oky to create new column if needed.
There are several ways of doing this.
One way is to create a second table, a lookup table, with two columns [ID] and [Text]. The ID column has a single row for each of your category types (1, 2, 3) and the second column contains the corresponding string value. Then you create a 1:* relationship between category type column and ID column. In a visual you can then build the visual with the information from the table containing the category type column and the string value from the new lookup table.
A second way is creating a calculated column in the original table using an IF or SWITCH statement.
Which solution is the best for you depends on how many different category types and how many rows of data you have in the data table. intuitively I would say that the lookup table option is better from a resource usage.
Cheers,
Oscar
Oscars solution should work. You could also create a Conditional Column in Power Query.
Add Column Tab > General Group > Conditional Column.

Excel PivotTable Count field as % of another Count field

I am using Excel from Microsoft Office 365 ProPlus.
Here's a really simple data table.
I want to build a Pivot Table around it to look like this...
... except that the "what I want" column (which is the count of items in Column C divided by the count of items in Column B) should be a part of the pivot table.
I have tried all sorts of things using calculated fields, calculations on fields, etc., to add the "what I want" column and just cannot make it work.
Can anyone help?
Calculated Fields only operate on the Sum of the elements in the data tables. Wherever you see a Field Name in the formula for a Calculated Field, picture it as meaning the sum of all elements for that field (that match any other row/column criteria in the Pivot Table).
Putting "= B / C" actually means "= SUM(B) / SUM(C)" for elements of columns B and C that fit that section of the Pivot Table.
The only way to achieve your goal is with two helper columns:
B Count: =COUNT([#B])
C Count: =COUNT([#C])
The sum of these columns then give you the count of columns B and C, so you can use these helper columns to give you what you want:
The Data Field based on the Calculated Field then says "Sum of What U Want", but it will always just be the result of your calculation, even if you change how the field is summarized through Value Field Settings. You can manually rename the Data Field, but it still needs to be different to the Calculated Field name you chose earlier.
Click in the Pivot Table, then go to the Analyze tab, click on Fields, Items, & Sets, then select Calculated Field. Your formula is probably
= B / C

excel vlookup in tables - search for row and report value in column using column name

I have a database table that is structured like this
SAP Number, FOW, WD, DG
In a different sheet I am using data from this list
It looks like this
SAP Number, WD, DG, ....
The SAP Number is given, WD and DG are searched using VLOOKUP
=VLOOKUP($A2,Objektive!$B:$M,10,FALSE)
This however is difficult to read and could be solved much easier.
I know that the search value is in $A2, and I know that the value is in a tabular named "WD".
Is it possible within Excel to search for the Row similar ot VLOOKUP, but use the column using the column name as [#[WD]]
Here some peudo-code
=VLOOKUPTABLE($A2,Data[#[WD]],FALSE)
If your data table starts from the first column, you can use the COLUMN function to determine the index of the column you want to return data from in the table using the name of that column.
=VLOOKUP($A2,Data,COLUMN(Data[WD]),FALSE)
Alternatively you can use Index/Match to directly reference the columns you want to match and return data from.
=INDEX(Data[WD], MATCH($A2, Data[SAP Number], 0))
If you create a table from the Excel (select any of the cells and press Ctrl + T) you gain access to named references which you can use in Excel formulas. Just make sure your data contains headers.

DAX Compare a Column imported from power query with another table's Column and return the result from the same row

I have a daily CSV file which has a column containing a big list of addresses (about 5000/day) received from a call center, some of those addresses contain the name of the neighborhoods around the city and it's usually in the first 5 words.
in another table i have the exact name of all the neighborhoods in one column and in another column in the same row i have the courier name which provides delivery service in that neighborhood.
I'm looking for a method in power pivot to search each row of the [Address] column & if a value similar to the neighborhood's name found give me the name of the courier of that neighborhood.
This an example for my data sets, the fist sheet describes 5 sample of my daily data, and the second sheet is districts information and their courier ID
Disclaimer - this method doesn't handle for similar words, only exact matches.
The easiest method I found is to make a calculated table. On the Modeling tab, click on New Table and enter this formula.
Results = SELECTCOLUMNS(
FILTER(CROSSJOIN(Addresses, Couriers), SEARCH(Couriers[District], Addresses[Address], , -1) > 0),
"Address", Addresses[Address],
"CourierID", Couriers[Courier ID]
)
This cross joins your two tables and then filters the results down to only where the District from the Couriers table can be found in the Address. As I said in the disclaimer, this is only looking for exact matches.
Then to get that back into the Address table, add a new column with this formula. This will look up the address into the table we just made and return the Courier ID.
CourierID = LOOKUPVALUE(
Results[CourierID],
Results[Address],
Addresses[Address]
)
The reason we need to do this in two steps is because the LOOKUPVALUE function cannot take expressions.

replace a column value having duplicates with another column if matched in MS EXCEL

I have a Table, say TABLE-1 with 4 columns. Columns are (ID, NAME, GROUP_NAME, IS_APPROVER), ID is not the primary key. There are many rows with same ID. Now I got a new Table, say TABLE-2 with Columns, (NEW_ID, OLD_IDs), in this table (TABLE-2), OLD_ID is the primary Key. I have to replace all the values of IDs in TABLE-1, with the NEW_ID (in TABLE-2) values compared using OLD_ID (in TABLE-2). How can I do this?
You could potentially use VLOOKUP to make it a little easier.
I added a new column to the first table and the formula for that column is simply
=VLOOKUP([#ID], Table2[#All], 2)
Assuming your tables look like the below:
You should just be able to use a combination of INDEX and MATCH to get your desired results:
=INDEX(TABLE-2[NEW_ID],(MATCH(TABLE-1[#ID],TABLE-2[OLD_IDs],0)))
If your data is not actually in tables but in ranges the general formula is:
=INDEX(ColumnFromWhichValueShouldBeReturned, (MATCH(LookupValue, ColumnAgainstWhichToLookup, 0)))
EDIT following further info from OP:
If not all the ID's are matched in TABLE-2 you can use the following:
=IFERROR(INDEX(TABLE-2[NEW_ID],(MATCH(TABLE-1[#ID],TABLE-2[OLD_IDs],0))), Table1[#ID])
In practice you can see this working below:
This is the solution..
Ref: https://www.ablebits.com/office-addins-blog/2014/08/13/excel-index-match-function-vlookup/
=INDEX(Table_2[NewIDs],MATCH(Table_1[#ID],Table_2[Old_ID],0))
Ex: =INDEX($K$2:$K$253,MATCH(B2,$J$2:$J$253,0))

Resources