I have the following spreasdheet:
pserial
sex
marstatb
age
10105101
1
5
92
10115101
1
1
63
10120101
2
4
56
10127101
1
2
38
10127102
2
2
25
10135101
2
1
37
10135102
2
-1
14
10135103
2
-1
10
10137101
1
2
35
10137102
2
2
29
Where pserial: Serial number of individual
Sex: male/female
marstatb: Marital status including cohabitees
I know that the person is divorced if marstatb= 4, and that the person is female if sex=2
I need to find the pserial value for the oldest divorced female.
I was thinking of using the filtering function, IF function for the criterias but I'm not sure how.
I think the INDEX function would be useful for this too.
UPDATE: This is my function so far:
=#FILTER(A2:A9282,MAXIFS(D2:D9282,B2:B9282,2,C2:C9282,4)=D2:D9282)
Using FILTER() & MAXIFS()
• Formula used in cell F2
=FILTER($A$2:$D$12,(MAXIFS(D2:D12,B2:B12,2,C2:C12,4)=D2:D12)*(B2:B12=2)*(C2:C12=4))
Another alternative is using INDEX() & AGGREGATE()
• Formula used in cell F4
=INDEX(A2:D12,AGGREGATE(15,7,ROW(A2:D12)/
((D2:D12=AGGREGATE(14,7,D2:D12/((B2:B12=2)*(C2:C12=4)),
ROW($ZZ1)))*(B2:B12=2)*(C2:C12=4))-1,1),0)
Using SORT() & TAKE()
• Formula used in cell F6
=LET(x,SORT(A2:D12,4,-1),
TAKE(FILTER(x,(INDEX(x,,2)=2)*(INDEX(x,,3)=4)),1))
With Headers:
=LET(x,SORT(A1:D12,4,-1),VSTACK(TAKE(x,1),
TAKE(FILTER(x,(INDEX(x,,2)=2)*(INDEX(x,,3)=4)),1)))
EDIT
For MS365 Users
• Formula used in cell F9
=TAKE(SORT(FILTER(A2:D12,(B2:B12=2)*(C2:C12=4)),4,-1),1)
With Headers:
• Formula used in cell F11
=VSTACK(A1:D1,
TAKE(SORT(FILTER(A2:D12,(B2:B12=2)*(C2:C12=4)),4,-1),1))
Related
End-goal: A column with the subtotals of groups (defined in the below table as all foods listed above Zucchini, incl Zucchini).
Current attempt: create a column to define groups using COUNTIF('count all 'zucchini' thus far'). Then use SUMIF to get the total cost for the current group.
Problem: I don't know how to do this without the COUNTIF column (since SUMIF needs range C:C to be resolved first). I'd like to have it in a single formula. I looked into array formulas but not sure if/how to apply that here.
FOOD COST COUNTIF(A2:A$2;"Zucchini") SUMIF(C:C;C2;B:B)
Apple 3 0 12
Pecan 7 0 12
Zucchini 2 0 12
Apple 4 1 23
Olive 8 1 23
Pecan 6 1 23
Zucchini 5 1 23
Apple 4 2 16
Olive 9 2 16
Zucchini 3 2 16
Any ideas on how to solve either the current problem or the end-goal problem? Thanks!
Put this in C2 and copy down:
=IF(A2="Zucchini",SUM($B$1:B2)-SUM($C$1:C1),"")
It basically sums everything to the row and subtracts what is already accounted for.
confuse wiht the Title
Well sorry my English doesn't look good
but I'll try to describe what I mean
Suppose I have this kind of values
0 A B C D F G H I J
1 20 =B1
2 10 =B3
3 30 =B5
4 8 =B7
5 9 =B9
6 4 etc.
7 79
8 67
9 63
10 45
as you seen above
I want to copy every value in cell B in two step down to cell D with Fill Handle
How can I do it ?
Any Formula I can use regarding this ?
Thanks before
In Cell D2 you can use the below formula, then drag down:
=INDEX(B:B,(ROWS($B$1:B1)*2)-1,1)
Please try:
=OFFSET(B1,ROW()-1,)
How can I prescribe which 6 of 8 cells excel uses to make an average?
e.g.:
A1 Art 86
A2 English 88
A3 Law 89
A4 Chemistry 83
A5 Biology 81
A6 Math 1 87
A7 Math 2 67
A8 PhysEd 72
e.g. Average 1 is A1:A6 / 6
e.g. Average 2 is [top 6 highest] / 6
e.g. Average 3 is Chemistry, English and the next top 4 highest / 6
I want to define the list where Average 1 = A1:A6/6, Average 2 = ?, Average 3 = ?
I assume the course descriptions are in column A and the scores are in column B and not Column A
B1:B6 =AVERAGE(B1:B6)
Top 6 =AVERAGE(LARGE(B1:B8,{1,2,3,4,5,6}))
Chemistry + English + top 4
=(SUM(SUMIF(A1:A8,{"Chemistry","English"},B1:B8))+SUM(LARGE((A1:A8<>"Chemistry")*(A1:A8<>"English")*B1:B8,{1,2,3,4})))/6
This last is an array formula and must be entered by holding down Ctrl + Shift while holding down Enter
A longer formula with the same result, but which can be normally entered:
=(SUM(AGGREGATE(14,4,((A1:A8="Chemistry")+(A1:A8="English"))*B1:B8,{1,2}))+SUM(AGGREGATE(14,4,(A1:A8<>"Chemistry")*(A1:A8<>"English")*B1:B8,{1,2,3,4})))/6
For #2, You can use Rank() to identify the top 6, then AverageIf() to average those <=6.
For #3, give Chem & English a value of 1, then use Rank() on the remaining 6 items. Then AverageIf() <=4. This is where it helps to put Chem & English at the top of the list.
Here's an example file showing this:
Click here for the file
Anyway, that's ONE way to solve it... hope it helps!
I want to check in Excel IF one value in one cell is lower in the following cells that comes after that cell. I have 54 cells with values. First I compare value in cell I1 with value in I2 to I54. If I find a value that is lower than I1 in cells I2 to I54 I want the text to be Check otherwise ok.
Then when I1 is done I want to check for cell I2 if there are any values in I3-I54 that is lower then I2. And so on to finaly check for I53 compared to just I54. I tried this
=IF(I1
Assuming your data looks something like this:
I
1 30
2 67
3 53
4 36
5 75
6 63
7 53
8 49
9 40
10 38
What I think you mean is that in I1 you want a formula that will tell you whether any of the below data (I2 - I54) is less than I1, if it is display "Check" otherwise display "Ok". You then want this to be the same in I2, but working out whether any of the data below I2 is less than the value in I2.
If this is correct then you could add a formula like the below in J1.
=IF(MIN(I2:$I$54)<I1,"Check","Ok")
By adding this in column J, you would end up with the following for the above data:
I J
1 30 Ok
2 67 Check
3 53 Check
4 36 Ok
5 75 Check
6 63 Check
7 53 Check
8 49 Check
9 40 Check
10 38 Ok
I have a datasheet with multiple columns that I want to search through - ending up with returning the top row value(s) in the found column(s). How to do this?
My idea would be to combine index with match, but I am rather lost for specific ideas...
January February March April May June
1 2 3 4 5 6
7 8 9 10 11 12
2 7 1 8 4 5
9 10 11 12 6 3
E.g. Search for: ID 3 - should return: March, June
Regards,
Nyborg
You need to add a VLOOKUP for each columns and after build the result
Following the Scheme:
A7 -> =IF(IFERROR(VLOOKUP($A$9;A1:A5;1;);"")="";"";A1) and autocomplete
D9 -> =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(CONCATENATE(A7;",";B7;",";C7;",";D7;",";E7;",";F7);",,";",");",,";",");",,";",")
D10 -> =IF(RIGHT(D9;1)=",";LEFT(D9;LEN(D9)-1);D9)
Formula for D9 & D10 it's only to have a good display of the results.
UPDATE Version:
Considering you agree to have the Row 7 ... You can simplyfy using the Result formula:
=INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);1))&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);2));"")&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);3));"")
List it's the name Range of Row 7. The formula shall be apply with Ctrl+Shift+Enter.
This formula collect the first 3 value.
If you want more, add for each nth value you have:
&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);3));"")
changing the last numer (in this case 3) and putting 4, 5, 6 ...
Obviusly if the result can be a lot, have few sense... Consider to use VBA !