Index/Match multiple columns in Excel - excel

I have 2 sheets. Sheet 1 is set up similarly to:
Keyword Domain Rank
A Z 1
B Z 2
C Z 3
D Y 10
E Y 15
B Y 20
And sheet 2 is set up like:
Keyword (Domain Z) (Domain Y)
A 1 -
B 2 20
C 3 -
D - 10
I'm trying to have a formula that will compare the keywords in Sheet 2 with those in Sheet 1 and then return the rank that corresponds to the correct domain (that's specified in Sheet 2 for that column). I can't get any formula I use to evaluate. I've used 2 formulas so far:
=INDEX(Raw!$H$11:$H$322, MATCH(A3,IF(Raw!$D$11:$D$322=All!$B$2,Raw!$B$11:$B$322),0))
The above formula works, to a point. The problem is that it simple pulls the domain for the first instance of the keyword found, which doesn't always match the domain in the column of sheet 2. The second formula I've tried:
=INDEX(Raw!$H$11:$H$322, MATCH(B3,MATCH($C$2,Raw!$D$11:$D$322,0)))

To make the values appear in the Sheet 2 table, use the following formula:
=SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$F$1),$C$2:$C$7)
This returns 0 for non-matches - you can either format the cells to display 0 how you want, or you can use the longer/uglier:
=IF(SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7)<>0,SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7),"-")
To calculate the rank on the first sheet based on the data from the second sheet:
=VLOOKUP(A2,$F$2:$H$5,MATCH(B2,$G$1:$H$1,0)+1,FALSE)
For sample purposes, this just put your sheet2 data in F1:H5.
This looks for the corresponding keyword and then uses match to pick the right column. I named the columns Z and Y, but if you need Domain included that can be done as well. Note that this causes an error since there is no E defined in your second table - is that the case? If so, it can be adjusted to account for no matches as follows (assuming Excel 2007):
=IFERROR(VLOOKUP(A6,$F$2:$H$5,MATCH(B6,$G$1:$H$1,0)+1,FALSE),"Rank Not Found")

You could also use PivotTable with Keywords in rows and Domain names in columns. It seems like that would do the job and be a more robust solution.

Related

Excel - sum if name is subset of another

Say I have a table like this in Excel (except the third and last column, which is what I want to obtain)
Name
Value
What I want
X
1
1
X-Y
1
2
X-Y-Z
0
2
X-V
1
2
So in column 3 I want to do a sumif which sums the column "Value" across all rows where Name is a subset of the given name in the row being looked at.
E.g. for row 2 the returned value will be 2 - because both X and X-Y is a subset of X-Y - so it sums these two rows' values.
How can I do this in a formula?
Found the solution myself.
In C2 put
=SUMPRODUCT($B$2:$B$5; --(IFERROR(IF(FIND($A$2:$A$5;A2)>0;1;0);0)=1))

How to use SUMIFS and SUMPRODUCT function **with a multiplier column** for summing values if criteria range exists in a range?

This question refers to this Stack Overflow question.
This is the original question:
A B C
a 3 d
b 1 a
c 8 e
d 5
I want to use SUMIFS function, sum range is B1:B4, if the corresponding value in column A exists in column C, sum the values in column B, in this case the sum will be 3 + 5 = 8.
The answer turned out to be:
=SUMPRODUCT(SUMIF(A1:A4,C1:C3,B1:B4))
I would like to create the same result, but with a multiplier on one of the ranges.
Here's my question:
A B C D
a 3 d 3
b 1 a 1
c 8 e 1
d 5 d 3
The only thing I would like to do differently is add a range D1:D3 that acts as a multiplier. In this case, the sum I want would be (3x3)+(5x3)= 24.
One challenge is that the ranges are different sizes in the "Test Data" google sheet linked below. The "Test Data" sheet is an example of how I would like to total daily calories based on the number of servings of items that I eat as dictated by the "multiplier column."
I would like the numbers in C2:C27 to be a multiplier and factored into the total in D36.
For example, if I ate 2 servings of Beef, then 2 servings worth of Beef's ​calories would be displayed in the daily totals below the data. Currently, using the formula =SUMPRODUCT(SUMIF(Meal_Items!$A$2:$A$100,$D$2:$D$28,Meal_Items!$B$2:$B$100)), only 1 serving of beef is weighted.
Test Data
See linked Test Data set above
The original question could also be solved with this formula
=SUMPRODUCT((COUNTIF(C1:C3,A1:A4)>0)+0,B1:B4)
using that version it's a simple matter to add one or more multiplier columns
=SUMPRODUCT((COUNTIF(C1:C3,A1:A4)>0)+0,B1:B4,D1:D4)
Given discussion in comments this formula should do what you want in either Excel or google sheets
=SUMPRODUCT(IFERROR(LOOKUP($D$2:$D$28,Meal_Items!$A$2:$A$100‌​,Meal_Items!$B$2:$B$‌​100),0),$C$2:$C$28)
If you have actually put A, B, C, etc into the header row (row 1) then this will not work until you either rename your header column labels appropriately or use data range references in place of the full column references I've provided.
=B2*INDEX(B:B, MATCH(A2, A:A, 0))+B2*INDEX(B:B, MATCH(C2, A:A, 0))
In E1 enter:
=IF(COUNTIF(C$1:C$4,A1)>0,1,0)
and copy down. Then in another cell:
=SUMPRODUCT((E1:E4)*(D1:D4)*(B1:B4))
Data is in column BWeights are in column DCriteria are in column E

Excel formula for multiple conditions and worksheets

The aim
I am try to create a formula which will allow specific information from 90 different worksheets, with an example of one such worksheet being below. Each work sheet represents data from a participant.
I want the data from the 90 work sheets to be summarised into the worksheet below.
The problem
The problem is that I need to create a formula that takes counterbalancing into account.
So in cell A3 of the second image I would to record the number of times the value 1 and 3 appears in column I of the first image.
The conditions
However, I would only like the numbers in column I to count if:
a) in column M of image 1 there is a value of 1
and
b) when the number in Column L is 1 and Column K is 1 or 4 OR when the number in Column L is 2 and the number in Column K is 3 or 4.
My attempt
=SUM('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$M$2,1*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$L$2,1*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$K$2:$K$41,1,4*(IF('[All_memories_301-389_improved.xlsx]Sirma 301:387Yanxin'!$I$2:$I$54,1,3)))))))
This did not work however and I have spent a long time on this and made changes but I still can't seem to get it to work.
Extra information:
In column I I want to count all the occurrences of 1 and 3 provided the specified conditions are met. The rows are not important, but rather, the column I information for each of the 90 spreadsheets.
New attempt with formula:
=COUNTIFS('[All_memories_301-389_improved.xlsx]381Christie'!$M$2, 1, '[All_memories_301-389_improved.xlsx]381Christie'!$L$2, 1, '[All_memories_301-389_improved.xlsx]381Christie'!$K$2:$K$23, AND(1,4), '[All_memories_301-389_improved.xlsx]381Christie'!$I$2:$I$23, AND(1,3))

Count with criteria for changing column in excel

I have a data looks like this:
a b c
1 3 4
2 3 3
4 1 2
2 4 2
In another worksheet, I want to do the following calculation:
whenever A1 returns a (header of data worksheet), count number of items that are smaller and equal to 2 in column "a". (result will be 2)
if A1 returns b, count number of items that are smaller and equal to 2 in column "b". (result will be 1).
A1 has already been preset with formula such that it will show a or b or c as conditions changed.
I need the formula to be lean... I actually have 6 headers, so if I keep on using if functions, I will probably have to set 6 if functions in one cell...that can be overwhelming. index match cannot provide a range to work on...Any suggestion? thanks
I don't know vba. If you could provide a workable vba code, i don't mind. but i don't know how to read it...>.< please provide user manual for that. lol, thank you~
If your data is found on Sheet1 and the a is found on column a, b is found on column b etc. enter this formula on then next sheet on b1 when a1 is the column value:
=COUNTIF(INDIRECT("Sheet1!"&a1&":"&a1),"<=2")
The Indirect is for adding text to your reference.
If your data sheet is Sheet1, you could try the array formula:-
=SUM((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Must be entered with CtrlShiftEnter
(actually there are 3 items less than or equal to 2 in column A)
Or you can use the SUMPRODUCT version if you prefer not to use an array formula:-
=SUMPRODUCT((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Or you can use this INDEX/MATCH method which is probably more efficient:-
=COUNTIF(INDEX(Sheet1!A2:C5,,MATCH(A1,Sheet1!A1:C1,0)),"<="&2)

Excel - Formula or Macro to fill a cell based on another cell that links to yet another cell

In Excel, I am trying to make a cell based of the values contained in two other cells.
I need Cells X and Y to have data based on Cells L and #, like so....
X Y L 1 2 3 4 5 6
A 6 1 1 6;1 6;1 7;1 7;2 7;2 8;1
B 7 2 4 6;1 6;1 7;1 7;2 7;2 8;1
So row A, has columns X and Y filled based of the values in the number columns. The specific number needed is what is filled in in column L.
I am not sure the best way to phrase this question. If my example doesn't make sense, I can try to clarify or provide more examples.
I have no idea if this can be done with fancy formulas or with a VBA macro or two. I am an excel noob.
If I've understood your question correctly you can do this with a combination of Left/Right, Index and search.
In my example images, the user inputs their value in column D, and then columns B and C use the formulea
=LEFT(INDEX($F2:$K2,1,$D2),(SEARCH(";",INDEX($F2:$K2,1,$D2))-1))
=RIGHT(INDEX($F2:$K2,1,$D2),(SEARCH(";",INDEX($F2:$K2,1,$D2))-1))
respectively
Here, the Index function returns the correct column to look at (i.e. the value chosen by the user, the Search function finds the position of the semi-colon, and the left/right functions return the values either side of the semi-colon.

Resources