Vlookup/index on 2 sheets and multiple values - excel

Sheet 1:
Column A: email
Column B: name
Column C: action
Sheet 2
Column B: name
*there are dulpicate names in sheet 1, so each name could have different action and email.
**there are some names in sheet 2 that are not in sheet 1
***there are over 1000 rows.
How do i return the values in sheet2 such that i have the emails, common names and action tgt. Horinzontally.

First, you need an additional column in Sheet1 which counts the occurrences of of each name. Second, in Sheet2, you need to match a name and its occurrence within Sheet1.
The picture below, shows (on a single sheet) an arrangement that you might want to adapt.
In my example I have allowed up to 5 email/action pairs per name, though the solution can obviously be adapted to the requirement of your data.
The solution uses a COUNTIF() function in the "input" table to generate the occurrence number of each name.
In the "output" table, the 5 helper columns identify the row number of the input table matching to the 1st, 2nd,... occurrences of the name, with a zero indicating no match. The SUMPRODUCT() function generates this row number. The remaining columns simply pick out the appropriate email/action from the input table.
The helper columns can be avoided in the "output", but this would be at the expense of replacing the single cell references such as G2 in =IF(G2>0,INDEX($B$2:$B$9,G2),"") with the corresponding SUMPRODUCT() expression. The IF() is necessary because the INDEX() function has a peculiar behaviour when its second argument equates to zero.
Getting the correct formula for the first row of Email/Action pairs in the output table (range L2:U2) in my picture is a bit tedious and there are ways around this (based on using the COLUMN() function to calculate the appropriate helper column number). However, the solution is intended to be something to be built on so I have kept it simple.
The solution assumes that each email/action pair in the input will be kept distinct in the output. So if a name in the input has two (or more) email/action pairs which have a common email, the solution does not combine the two actions against that common email. It is possible to do this but it will require additional information to be added to the "input" table - namely the occurrence of actions associated with a specific name/email combination.

Related

how to sum columns using column headers and bridge tables in excel

I have two sets of data in excel, set 1 is the raw data, and set 2 is a bridge table. The desired output is also added. How should I prepare for this formula.
set 1:
set 2:
output expected:
Here, a solution that assumes a variable number of headers and no specific pattern in the column names. Assumed no Excel version constraints as per tags listed in the question. In cell H1, put the following formula which spills the entire result all at once:
=LET(in, A1:F5, lk, A8:B12, header, DROP(TAKE(in,1),,1), A, TAKE(lk,,1),
B, DROP(lk,,1), data, DROP(in,1,1), REDUCE(TAKE(in,,1), UNIQUE(B),
LAMBDA(ac,bb, LET(f, FILTER(A, B=bb),values, CHOOSECOLS(data,XMATCH(f, header)),
sum, MMULT(values, SEQUENCE(ROWS(f),,1,0)), HSTACK(ac, VSTACK(bb, sum))))))
Here it the output:
We use LET function with two input ranges only: in, lk, so the rest of the names defined depend on such range names. It makes the formula easy to maintain and to adapt to your real scenario.
Using DROP and TAKE we extract each portion of the input ranges: header, data, A, B (columns from the second table). We use REDUCE/HSTACK pattern to concatenate the column of the result on each iteration. Check my answer from the question: how to transform a table in Excel from vertical to horizontal but with different length for more information.
We iterate by unique values of B and for each value (bb) we select the column A values (f). We use XMATCH to select the corresponding index columns from header (it doesn't include the date column). We use CHOOSECOOLS to select the corresponding columns from data (values). Now we need to sum by column, and we use MMULT for that. The result is in sum name. Finally, we use HSTACK to concatenate the selected columns one each iteration, including as header the unique values from B.
Note: Instead of MMULT function, you can use the following array function, it is a matter of personal preferences:
BYROW(values, LAMBDA(x, sum(x)))
You could try SUMIFS with the wild card character for each row. For example, for the first column, put the following formula and drag it down.
=SUMIFS($B2:$F2,$B$1:$F$1,"=A*")
Then do the same thing for the other columns, e.g. for column B:

Appending two lists in excel

I have been trying and searching how to append two lists in excel to use in a formula. The lists do not exist in columns, they are created using a formula. I want to combine the two lists in a single one, not to show the values but to use the new list in a formula. I am using excel 365 (UNIQUE function). Let me replace my initial text by a real small case.
I have an excel file with 3 work sheets. Sheet1 is:
Sheet2 is:
Now I want to run some analysis in Sheet3. In my example I want to count how many unique values from column A have column B containing one of the letters 'a', 'b, 'c', or 'd'. For instance, in Sheet1, the letter 'a' appears in all rows. Column A has 3 unique values. So my result for 'a' is 3. The letter 'b' does not appear for the case where column A is '3'. Therefore the result for 'b' is '2'.
So I create a Sheet3 to show my results. The first column contains a list of letters {a, b, c, d}. I then use the formula:
=COUNT(UNIQUE(FILTER(Sheet1!$A$1:$A$100, ISNUMBER(SEARCH(A1, Sheet1!$B$1:$B$100)))))
From inside out: the SEARCH function looks in cells B1 to B100 (I can live with specifying a larger range) where is the position of the value specified in column A (of the current sheet). If it does, then SEARCH returns a number. I check if the return value is a number (ISNUMBER) and use this to filter values in column A of Sheet1. I then apply the UNIQUE function to these values and finally count them.
Then I do the same with values in Sheet2. And it works. This is the output:
Column B is the number of unique values (as specified above) from Sheet1 and Column C the same from Sheet2.
So far so good. But now I want to have the counting of unique values globally. Not for each Sheet. One cannot just add the values from column B and C, as there might be an overlap. For example, the result for 'a' should be 3, not 5.
The solution here would be to grab the two unique lists (one from Sheet1 and the other from Sheet2), join them, UNIQUE this new list, and count. How do I join them ? That is my question.
Note that this 'counting of unique values' is just an example. I might want to find the maximum, or sort them, or find only prime numbers, or the average, or the median, or something else. So I need a general approach to join the results.
I got options close to a workable thing when all the data is in the same worksheet.
Finally, note that the data size I have is not huge, but it is large (thousands of lines at the most).
Here is something you could try:
=LET(x,{"A","B","C"},y,{"D","E"},z,CHOOSE({1,2},x,y),cnt,MAX(COUNTA(x),COUNTA(y)),seq,SEQUENCE(cnt*2),final,INDEX(z,MOD(seq-1,cnt)+1,CEILING(seq/cnt,1)),FILTER(final,NOT(ISERROR(final))))
Here both 'x' and 'y' variables are placeholders for your two (vertical) arrays. In this case I used: {"A","B","C"} and {"D","E"}. Assuming you just want to place the 2nd array directly under the 1st one, the above suggestion does just that:

OFFSET / INDIRECT function trouble

I have two sheets within a workbook, the first with several thousand lines of expenses, separated by individuals, and the second a summary of totals and such.
On the second sheet, I've created a reference to the first to insert each individual's name (i.e. B4: ='Card Transactions'!D89). I'm having difficulty with the syntax for returning the total of each individual's total, which is in a predictable cell in the first sheet relative to the name (down 1, right 7).
I've tried the following:
=offset(indirect(B4),1,7) with only a reference error in return. This seems like it should be relatively simple but I'm not having any luck. . . any suggestions?
use this:
=OFFSET(INDIRECT(MID(FORMULATEXT(B4),2,300)),1,7)
note:
this only works if the formula in B4 only contains the one cell reference.
This is a volatile function and will cause a noticeable lag in calculations if used too many times.
The following should work for you as long as your data follows these rules:
Your columns have headers
The names are all in the same column
And you are able to set the range with row numbers and not just full columns
Let's say your first sheet is set out like this:
And you want your second sheet like this:
And your sheets are named:
Sheet1
Sheet2
This is the formula in B2 of Sheet2:
=INDEX(Sheet1!$A$1:$H$9,MATCH(A1,Sheet1!$A$1:$A$9,0)+1,MATCH("Column 8",Sheet1!$A$1:$H$1,0))
And here's what it does:
Your index array is the entire blue area, this can be the whole sheet but can't be a full column reference, the row number must be specified. In this example, the index array is $A$1:$H$9 and the $ signs mean the range won't move when you drag down the formula, so they are important!
Your first match finds the row number, it uses the name (in this case 'bart') as the lookup value, and the purple area as the array. In this example the row array is $A$1:$A$9 and the row numbers must match the row numbers in the index array. The match has a "+1" at the end, so it will find the matching row, then add one row down to get your offset.
Your second match finds the column number, it will need to use the name of your column. In this example the column array is $A$1:$H$1 and the column letters must match the column letters in the index array.
Let me know if this doesn't fit your problem, I'm sure we can figure it out.
Thanks.

Why am I obtaining this strange result adding all the values in 2 Excel columns?

I am not into Excel and I have this problem trying to sum the values of 2 different column and put this result value into a cell.
So basically I have the D column containing 2 values (at the moment only 2 but will grows without a specific limit, I have to sum all the values in this column). These value are decimal values (in my example are: 0,3136322400 and 0,1000000000).
Then I have an I column containing the same type of value (at the moment only one but also the values in this column can grow without a specific limit...in my example at this time I have this value −0,335305)
Then I have the K3 cell where I have to put the sum of all the valus into the D column and all the values into the I column (following my example it will contain the result of this sum: 0,3136322400 + 0,1000000000 −0,335305.
Following a tutorial I tried to set this simple forumla in the K3 cell:
=SUM(A:I)
The problem is that in this cell now I am not obtaining the expected result (that is 0.07832724) but I am obtaining this value: 129236,1636322400.
It is very strange...I think that maybe it can depend by the fact that the D and the I column doesn't contain only number but both have a textual "heder" (that is the string "QUANTITY" for both the cells). So I think that maybe it is adding also the number conversion of this string (but I am absolutly not sure about this assertion).
So how can I handle this type of situation?
Can I do one of these 2 things:
1) Adding the column values starting from a specific starting cell in the column (for example: sum all the values under a cell without specify a down limit).
2) Exclude in some way the "header" cells from my sum so the textual values are not considered in my sum.
What could be a smart solution for my problem? How can I fix this issue?
The sum function can take several arguments.
=sum(d2:d10000, i2:I10,000, more columns )
This should remove the header from the calculation.
If you turn your data into an Excel Table (Insert > Table), you can use structured referencing to address a table column, excluding the header.
=SUM(Table1[This Header],Table1[That Header])
Then you don't need to reference whole columns. If you add new data to the table, the formula will take that into account.

Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet

This is a confusing request.
I have an excel tab with a lot of data, for now I'll focus on 3 points of that data.
Team
Quarter
Task Name
In one tab I have a long list of this data displaying all the tasks for all the teams and what Quarter they will be on.
I WANT to load another tab, and take that data (from the original tab) and insert it into a non-list format. So I would have Quarters 1,2,3,4 as columns going across the screen, and Team Groups going down. I want each "task" that is labeled as Q1 to know to list in the Q1 section of that Teams "Block"
So something like this: "If Column A=TeamA,AND Quarter=Q1, then insert Task Name ... here."
Basically, if the formula = true, I want to print a list of those items within that team section of the excel document.
I'd like to be able to add/move things around at the data level, and have things automatically shift in the Display tab. I honestly have no idea where to start.
If there is never a possibility that there could be more that 1 task for a given team and quarter, then you can use a formula solution.
Given a data setup like this (in a sheet named 'Sheet1'):
And expected results like this (in a different sheet):
The formula in cell B2 and copied over and down is:
=IFERROR(INDEX(Sheet1!$C$2:$C$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$B$2:$B$7=B$1),),0)),"")
I came across this situation. When I have to insert the values into a table from an Excel sheet I need all information in 1 Column instead of 2 multiple rows. In Excel my Data looks like:
ProductID----OrderID
9353510---- 1212259
9650934---- 1381676
9572474---- 1381677
9632365---- 1374217
9353182---- 1212260
9353182---- 1219361
9353182---- 1212815
9353513---- 1130308
9353320---- 1130288
9360957---- 1187479
9353077---- 1104558
9353077---- 1130926
9353124---- 1300853
I wanted single row for each product in shape of
(ProductID,'OrdersIDn1,OrderIDn2,.....')
For quick solution I fix it with a third column ColumnC to number the Sale of Product
=IF(A2<>A1,1,IF(A2=A1,C1+1,1))
and fourth Column D as a placeholder to concatenate with previous row value of same product:
=IF(A2=A1,D1+","&TEXT(B2,"########"),TEXT(B2,"########"))
Then Column E is the final column I required to hide/blank out duplicate row values and keep only the correct one:
=IF(A2<>A3,"("&A2&",'"&D2&"'),","")
Final Output required is only from Column E
ProductID Order Id Sno PlaceHolder Required Column
9353510 1212259 1 1212259 (9353510,'1212259'),
9650934 1381676 1 1381676 (9650934,'1381676'),
9572474 1381677 1 1381677 (9572474,'1381677'),
9632365 1374217 1 1374217 (9632365,'1374217'),
9353182 1212260 1 1212260
9353182 1219361 2 1212260,1219361
9353182 1212815 3 1212260,1219361,1212815 (9353182,'1212260,1219361,1212815'),
9353513 1130308 1 1130308 (9353513,'1130308'),
9353320 1130288 1 1130288 (9353320,'1130288'),
9360957 1187479 1 1187479 (9360957,'1187479'),
9353077 1104558 1 1104558
9353077 1130926 2 1104558,1130926 (9353077,'1104558,1130926')
You will notice that final values are only with the Maximum Number of ProductSno which I need to avoid duplication ..
In Your case Product could be Team and Order could be Quarter and Output could be
(Team,Q1,Q2,....),
Based on my understanding of your summary above, you want to put non-numerical data into a grid of teams and quarters.
The offset worksheet function will work well for this in conjunction with the match or vlookup functions. I have often done this task by doing the following steps.
In my data table, I have to concatenate the Team and quarter columns so I have a unique lookup value at the leftmost column of your table (Note: you can eventually hide this for ease of reading).
Note: You will want to name the input range for best formula management. Ideally use an Excel Table (2007 or greater) or create a dynamically named range with the offset and CountA functions working together (http://tinyurl.com/yfhfsal)
First, VLOOKUP arguments are VLOOKUP(Lookup_Value,Table_Array,Col_Index_num,[Range Lookup]) See http://tinyurl.com/22t64x7
In the first cell of your output area you would have a VLOOKUP formula that would look like this
=Vlookup(TeamName&Quarter,Input_List,Column#_Where_Tasks_Are,False)
The Lookup value should be referencing cells where you have the team names and quarter names listed down the sides and across the top. The input list is from the sheet you have the data stored. The number three represents the column number the tasks are listed in your source data, and the False tells the function it will only use an exact match in your putput.

Resources