Indexing questions with array formulas in Excel - excel

I'm new to array formulas in Excel and my brain has been trained in R for too long, so I'm sorry if this question is simple or too specific. I have data that looks like this:
ID Iteration Value Group1 Group2
2 1 100 0 0
2 2 85 1 0
2 3 28 0 0
3 1 94 1 0
5 1 83 0 1
5 2 50 1 1
6 1 94 0 0
6 2 28 1 0
I want to use array formulas to query the data in a few different ways. I want to:
For each ID, find the first iteration that has Group1 = 1.
For each ID, what is the maximum value when Group1 = 1.
For each ID, how many iterations of Group1 = 1 did it take to get to the maximum value when Group1 = 1.
I've figured out how to specify the maximum for each ID via: {=MAX(IF(A:A=A2,C:C))}
Any assistance would be appreciated. I've gone through a few quick tutorials so far, and I'm willing to look through any other good resources you may know of.

Have a look at this and tell me what you think - particularly for question 3
My setup looks like this
All formulas drag down and they are as follows:
Formula in B14 (Question 1)
{=INDEX($B$2:$B$9,MATCH(1,($A$2:$A$9=A14)*($D$2:$D$9=1),0))}
Formula in G14 (Question 2)
{=MAX(($A$2:$A$9=$F14)*($D$2:$D$9=1)*$C$2:$C$9)}
Formula in K14 (Question 3)
{=SUM(($A$2:$A$9=J14)*($C$2:$C$9=G14)*$B$2:$B$9)}
Update
If you want to know how many times in ID=2 that Group1=1 before we reach the maximum we found for ID =2 in question 2, then I'd proceed like this:
Add another column to your data, I labeled it: Group1 Passes. Placing this in the new column, F2, and drag down.
=COUNTIFS($A$2:A2,A2,$D$2:D2,1)
You can then use the following in K14
=SUM(($A$2:$A$9=J14)*($C$2:$C$9=G14)*($D$2:$D$9=1)*$F$2:$F$9)

Related

Formula to put 1 in the first value and 0 for the rest. Duplicate dataset

I'm looking for a smart way to indicate only one row with duplicated values. I need it to help my pivot table a little.
Id Description Estimation(h) Formula
1 Desc1 20 1
1 Desc2 20 0
1 Desc3 20 0
2 Desc4 30 1
2 Desc5 30 0
2 Desc6 30 0
This looks quite simple: I just put the value 1 as the first value, and the rest of the column is based on the following formula:
=IF(A2=A3;0;1)
(I've put this formula in cell D3)
This option will work even if the Id is not sorted:
=--(COUNTIF($A$2:A2,A2)=1)

Index-Match function with NOT EQUAL criteria

I am trying to use the index with match function to give me the order of people based on their rankings. My data is something like this:
A B C
1 Rank Name Score
2
3 1 Joe 100%
4 3 Bob 80%
5 1 John 100%
6 2 Dan 90%
7
8 RankOrder Name
9 1 =index(b3:b6,match(1,a3:a6,-1)) Result = Joe
10 1 =index(b3:b6,match(1&<>"b9",a3:a6,-1)) Result = John **HELP
11 2 =index(b3:b6,match(1&<>"b9&b10",a3:a6,-1)) Result = Dan **HELP
The first formula is to find who has a ranking of 1 or greater, then the second and third formula is where I'm struggling. I need to find who the has the next ranking closest to 1 but has not already been outputted in cell B9. Then the next formula would be the same but not someone that's been outputted in cell B9 & B10. Hopefully this make sense.Thanks!
Use index and aggregate with countif for aggregate's k factor.
=INDEX(B$1:B$6,AGGREGATE(15,6,ROW($3:$6)/(A$3:A$6=A9),COUNTIF(A$9:A9,A9)))

FCR calculations in excel

I am trying to work the (First Contact Resolution) FCR in excel however so success.
Does anyone know an automated formula used in excel?
We have been trying to use formulas to check how many times a customer with the same customer ID calls us in 7 days.
Assuming your requirement
ID Date Calls Count in last 7 days from today
1 13-Mar-17 2
2 14-Mar-17 0
5 15-Mar-17 1
1 16-Mar-17 2
3 17-Mar-17 1
5 18-Mar-17 1
7 19-Mar-17 1
9 20-Mar-17 1
1 21-Mar-17 2
13 22-Mar-17 1
2 23-Mar-17 0
17 24-Mar-17 0
5 25-Mar-17 1
21 26-Mar-17 0
Putting ID in Column A and Dates in Column B and records starts from row 2
put this formula in Cell "C2":
=COUNTIFS(A:A,A2,B:B,">="&TODAY()-6,B:B,"<="&TODAY())
and drag it all way down to see the number of calls
or put this formula if you want to calculate last 7 days from the date in sheet:
=COUNTIFS(A:A,A2,B:B,">="&B2-6,B:B,"<="&B2)
Please let me know if you meant something else as I tried my best to assume the senario.

Find Largest Value in one cell and then display a different cell in the same row

This was a fairly difficult question to put to words but hopefully the example data and my attempt will help
I have the following
Apple 17 1 0 0 0 0 0 0 0 0 0 0
Orange 14 1 15 1 6.67 1 6.67 1 6.67 2 13.33 10
Banana 15 3 5 0 0 0 0 0 0 0 0 1
Cherry 13 1 12 2 16.67 2 16.67 2 16.67 2 16.67 2
Peach 16 4 12 1 8.33 1 8.33 2 16.67 2 16.67 8
Strawberry 12 5 6 1 16.67 1 16.67 1 16.67 1 16.67 7
I am trying to find the max value in M and then display A from the same row. So in this example the max value would be 10 and "Orange" should be displayed.
It should be noted that I am using 2 sheets, "Data" has my output and "Raw Data" has... the raw data
=VLOOKUP(MAX('Raw Data'!M1:M6), A1:M6, 1, FALSE)
This produces #N/A and I think it might have something to do with my data either not being formatted into a table (though doing so seems to fail with a different error) or running from one sheet to the other.
Any input would be greatly appreciated
VLOOKUP requires that the value to find is in the first column.
Use INDEX/MATCH:
=INDEX(A1:A6,MATCH(MAX(M1:M6),M1:M6,0))
Try this =INDIRECT(ADDRESS(MATCH(MAX(M1:M6),M1:M6,0),1))
I recomend using Index Match as Scott Craner has shown.
But if you are set on using vlookup:
I will first shortly explain vlookup as how I have understood it.
First a limitation, vlookup can only return values to the left of your search range, i.e you cant use negative numbers i.e,
=vlookup(Max('Raw Data'!M1:M6), A1:M6, **"-1"**, False)
Secondly, vlookup is structured like this:
=vlookup(The value you want to search for, the range you want to work with, which column you want to return a value from (1 means the first column).
vlookup will allways search for the vale you want to search for in the first column.
So in your data:
You are telling vlookup to search for the maximum value that exists in the range M1:M6. In this case 10 right?
You are telling vlookup to search for this value in column A which contains the fruits. This is where it goes wrong.
My solution to this would be to move all the fruits names to the N column (to the left of you values you want to search).
In code:
In the N Column:
Put = A and the row number
Now do a vlookup like this:
=vlookup(Max('Raw Data'!M1:M6), M1:N6, 2, False)
I hope this can solve your problem.
Best regards,

Finding the first specific value above a certain cell

I'm looking for a way to find the first specific value above a certain cell.
Using the example below, in the result column every time I hit a A in COL2, I need to substract the value in COL1 to the first A value above.
The trouble seems finding a way to keep the range dynamic...
I thought of =IF(B5="A";A5-INDIRECT("A"&MATCH("A";B:B;0));"")
But of course that only works for the first one as Match will always pick up the first one.
Any ideas? Thanks!
Example :
COL1 COL2 Result
1 A
2 0
3 0
4 A 4 - 1 = 3
5 0
6 A 6 - 4 = 2
7 0
8 0
9 0
10 A 10 - 6 = 4
Try this:
=IF(AND(ROW(B2)<>2,B2="A"),A2-INDEX($A$1:$A1,AGGREGATE(14,6,ROW($1:1)/($B$1:$B1="A"),1)),"")
The AGGREGATE() Function was introduced in 2010.
In D2 enter =IF(B2="A",A2-INDIRECT("A"&MATCH("A"&(E2-1),F:F,0)),"")
In E2 enter =IF(B2="a",COUNTIFS($B$2:B2,"a"),"")
In F2 enter =B2&E2
Copy formulas from D, E and F down all your rows
Column D is the result you're looking for

Resources