Excel formula to look up date that corresponds with 2nd 'non zero' value in column - excel-formula

In an excel model with two columns, column A = date by month, column B = cash projections (only two values in column B). Hoping to create a formula to search column b for the second value and return the corresponding month from column A.
In example below, looking for formula to return 'May 20' as answer
Column A
Column B
Jan 20
240,000
Feb 20
Mar 20
Apr 20
May 20
345,000
Jun 20
Tried using a min/max function, however, the second value is not consistently higher or lower than the first value. Assuming it can be done with some type of INDEX or LOOKUP function, however, I am unsure of how to select the second non-zero value

Related

Find an intersecting value for each row and column in excel

I have monthly data in rows in column A. I also have monthly data in headers from column B to Column G. In Column H i have current month populated for all rows. I would like to display the value where, for example if the month in row is Jan and current month is Mar, then find the value where Jan and Mar intersect and do this for all rows. I tried using the following formula in Column J but it only gives the first value when it works. The result in Column I is desired. Attached is the picture for clarity.
=INDEX(B1:H2,MATCH(A2,$A$1:A2,0),MATCH(A2,$B$1:H2,0))
You can do it with SUMPRODUCT.
I made a fake dataset with different values than the ones you show, so i could test properly if changing Current month would work.
It works even if column CurrentMonth holds different months
My formula is:
=SUMPRODUCT(--($B$1:$G$1=H2);B2:G2)
This is how it works:
--($B$1:$G$1=H2) will return an array of 1 and 0 if range B1:G1 is equal to current month in that row. So in case CurrentMonth=Mar then it will return {0;0;1;0;0;0}
With SUMPRODUCT we multiply previous array by range B:G in current row, so for row 2, it would be B2:G2. So as example, it would be {0;0;1;0;0;0} * {1;2;3;4;5;6} = {0;0;3;0;0;0} and we sum up this array, getting 3
just use INDEX with one MATCH:
=INDEX(B2:G2,,MATCH(H2,$B$1:$G$1,0))

date based on yes or no value in another column

Column G will either be blank or have a yes or no in it. Column L has a date value in it. IF column G has a yes in it I want column R to subtract 9 months from the date in column L. If column G is blank or no I want Column R to remain blank.
Enter this formula in column R (the below formula will work for row 2):
=IF(G2="Yes",DATE(YEAR(L2),MONTH(L2)-9,DAY(L2)),"")
Note that the adjustment of 9 months might look a bit odd. If your date is, say, 30 November 2018, the formula is supposed to return 30 Feb 2018. However, since no date exists, it will instead return 02 March 2018 (which is Excel's way of saying as two days after 28 February 2018).

If condition to count column values based on index number

I have 14 column with 1st column (say A) containing the month value (1 for Jan, 2 for Feb and so on). Colum B contain a number representing 2017 year value. For the next 12 columns starting column C onwards, there are values for each month of 2018 starting from Jan 2018 till Dec 2018. In Col 15, i want to sum value of 2017 (Column B) with corresponding months in 2018 based on the month value in Column A. For example, if the month value is 3, then the result should give me the sum of values in column B(2017) + column C(Jan2018) + column D(Feb 2018) + column B (Mar 2018). Since month value 3 represents March 2018.
I tried to use the function Choose but seems too length. Is there a smaller and easy function?
=SUM(B2:INDEX(C2:N2,1,A2))
INDEX(C2:N2,1,A2) here gives the reference within C2:N2 at row 1 and column from cell A2. The range from SUM then becomes B2 to the reference obtained from INDEX.

How to find number of matching values with an ID?

I have a unique list of IDs of people on two separate sheets. One for initial 'registration data' which is the master data list. In column A is the ID, column B is their town of residence and column C is the date in which the person was added to the list.
I send out sheets to the different towns every month to receive some more data about the new people added to the list, and every month (the same month) they should send it back to me. This received data goes onto a second sheet, with again: column A for person, B for town, and C for month data received.
I need to check how accurate the towns are in getting the data back to me on time. So I need to count the number of forms on the second sheet where the month is the same as the initial month on sheet number one, and the towns match too.
I have tried COUNTIFS with VLOOKUPs but am having no luck. I want to avoid having to make an interim data table as much as possible because I need the process to be slick and automatic.
Could this be done with a SUMPRODUCT?
For example:
Sheet 1 (initial) Sheet 2 (received)
123, TownA, Feb 123, TownA, Feb
124, TownB, Feb 124, TownB, Mar
127, TownB, Mar 127, TownB, Mar
130, TownC, Mar 130, TownC, Mar
220, TownC, Apr (we didn't receive back 220)
OUTPUT SHEET
Feb Mar Apr
TownA 1 0 0
TownB 0 1 0
TownC 0 1 0
As you can see, of the five forms we only received three in the month we were supposed to. I want it in the view above, and don't really want to have to make a new sheet with the IDs to match the months up.
In Sheet3 with Feb in C1, Mar in D1 and Apr in E1 and 123 etc in A2 etc, in B2:
=VLOOKUP(A2,Sheet1!A:B,2,0)
in C2:
=(INDEX(Sheet1!$C:$C,MATCH($A2,Sheet1!$A:$A))=C$1)*(INDEX(Sheet2!$C:$C,MATCH($A2,Sheet2!$A:$A))=C$1)
C2 copied across to E2 and B2:E2 copied down to suit.
Then select A:E and DATA > Subtotal At each change in: (ColumnB), Use function: Sum, Add subtotal to: check Feb, Mar, Apr, Summary below data and OK.
Copy A:E, Paste Special, Values over the top and apply filter. Filter ColumnB, Text Filters, Custom Filter..., contains Tot, OK.
In the first populated cell in ColumnB enter =Bn (where n is the row number immediately above that cell, though not visible) and copy down to suit.
Hide or delete the totals row to suit.

excel formula to extract dates with highest trade count

I need excel formula to show the dates when the trade count was maximum. Below mentioned are the excel columns
trade count. date
10 9 jan
12 8 jan
12 7 jan
Result : 7 jan & 8 jan
so the result can be highlighted in two different rows. or whatever convenient format.
kindly advice how it can be done easily.
Let your column C provide you with all the dates on which the MAX happens. You can always hide column C later.
Let C1 be the maximum from column A:
=MAX(A:A)
Now in each row, column C can build up your final output string. Copy from C2 down:
=IF($C$1=A2,TEXT(B2, "dd mmm"),"")
This gives you a column of either blank values, or the dates you need (correctly formatted as text).
Use column D to build up your final output string, by looking down column C:
=IF(C2="",IF(D3="","",D3),IF(D3="", C2,D3&" & "&C2))
Your result string will be given by cell D2.

Resources