Google Spreadsheet: Find the largest number within a date range - excel

I have three columns. One has a date, one a numerical value, and the last a text value. I want to call from a different sheet the nth largest number within the last month, and then in the cell beside it, the text value corresponding with that row. The column headers are named ranges for ease, and titled Amount, Date and Name.
Amount Date Name
------ ----------- --------
5 11/11/2013 Fred
30 5/11/2013 Bob
5.2 23/11/2013 Jack
40 29/10/2013 Tim
If I wanted to just get biggest number, I could do "=Large(Amount;1)" which would return 40, but I'm looking to get the largest amount in the last month (not just the last 30 days) which should return 30.
What I'm currently doing to pull the name (which will give name next to the largest value, not the largest value in the last month) is "=INDEX(Name,MATCH(Large(Amount;1),Amount,0))"
All of this is being done in Google Drive on their spreadsheet.
Thanks!

You can use the filter function, like this:
=LARGE(FILTER(A:A, YEAR(B:B) = 2013, MONTH(B:B) = 11), 1)
This means: get the max value from column A filtered based on the B column, where year is 2013 and month is 11.

zord's answer looks good for November 2013 but I think you want the "last month" so on December 15th assuming you want any date after November 15th then you can use a similar approach but use EDATE function to get a date one month back from today, i.e.
=LARGE(FILTER(A:A,B:B>EDATE(TODAY(),-1)),1)

Related

How get a value looking only for last day of a given month available?

In column A I have a list of dates and in column B I have values:
A B
01/01/2020 10
28/01/2020 20
03/02/2020 30
04/03/2020 40
How to get (for example value 20) looking only for last day of a given month (for example January) available?
You can use MAXIFS to get the last date in the month and VLOOKUP to get the matching value e.g. if the month number is in C2:
=VLOOKUP(MAXIFS(A2:A5,A2:A5,">="&DATE(2020,C2,1),A2:A5,"<="&EOMONTH(DATE(2020,C2,1),0)),A2:B5,2,FALSE)
EOMONTH with a zero gives you the last day in the current month (i.e. 31/1/20 in this case)

Return last day per month (and week) in dataset

I have a large amount of daily stock market closing data that I need to report on, however I only need the last day of the month from each data set.
Given the dates of each month will differ year to year depending on weekends and public holidays I can't just use =EOMONTH(A2,0)
How do I extract, just the last day of each month from a data set probably using the MAX functionality in some way. Then I can just do a Vlookup to get the data for that date,
[![Share Price Sheet][1]][1]
If your date column is sorted by small to large, index() and match() could solve this problem.
Try to use:
=INDEX(A:A,MATCH(EOMONTH(DATE(D2,E2,1),0),A:A,1))
which point is set third argument to 1 in MATCH function.
If you want to get close price, in G2 cell write:
=VLOOKUP(F2,A:B,2,FALSE)
Since the last date is found on the dataset you have, you can just select distinct your year & month in a new sheet, create a helper column combining the 2 columns.
Create the same helper column in your original dataset, sort dates by newest to oldest. And you can vlookup the exact date. If you just want the day part of the date, extract the date from the Date itself with the day formula
You can do this just by Pivot Table
Select your data (I used a snipped only)
Insert a Pivot Table
Use Year, Date and Close as your Row labels
Use Date also as a value field
Set Date in your value field to show Max, format to actually show dates and rename if you want, e.g. "Last Day"
Click any date under any month in the row labels > Filter > Top-Ten > Choose to filter top 1 under Last Day and confirm.
Format your pivot table to your liking, maybe hiding subtotals.
My end result looks like:
You could use a combination of EOMONTH and WORKDAY.
For example:
The date you're looking at is 21st November 2019.
=EOMONTH(DATEVALUE("21 Nov 2019"),0)+1 will return 1st December 2019.
30th November is a Saturday, and for some reason the 25th to 29th November are holidays.
=WORKDAY(EOMONTH(DATEVALUE("21 Nov 2019"),0)+1,-1,{43798,43797,43796,43795,43794}) will return 22nd November as last working day of the month.
Using cell references (D3 = Date, A1:A5 are the holidays):
=WORKDAY(EOMONTH(D3,0)+1,-1,$A$1:$A$5)

Automatically change excel cell value depending on current Month

Stock analysis Dashboard. I need to compare the stock from today vs the previous 6 months.
My stock data
Cell A1:R1 - month data example Cell A1= June 2017, B1= 7/2017 ....till R1= December 2018.
Cell A2:R2 Stock numbers data example A2=23, B2=25,........till R2=50.
IF I want to see the stock today month which is July 2018= M1 vs six months February 2018 H2 and the stock level calculation will which is M2=26 - H2= 30 =-4.
But instead of entering formula every time I need to be updated every month based on the today month?
Any tips on how to do it?
Thanks
I also miss a date...
If you use today() function to identify today's date you can use:
=HLOOKUP(TODAY(),$A$1:$S$2,2)-HLOOKUP(DATE(YEAR(TODAY()),MONTH(TODAY())-5,1),$A$1:$S$2,2)
If you need a cell with a specific date, replace today() formula with that cell.
I find the question a bit confusing. If A1 is June 2017, I am missing a month if R1 is December 2018 and July 2017 is in M1. Also, even though you said 6 months, I am assuming that you want 5 months so that July compares to February.
This response assumes that A1 is wrong but R1 and M1 (and B1 through R1 are accurate) and that the values in A1 through R1 are actually an Excel date that is formatted as m/yyyy (as opposed to some text representation of a date).
This formula is further complicated since I do not know what day is used in the date representation in A1 through R1, hence I am adapting both that date and the current date to be a fixed day of the month (I chose the first day of the month in my formula).
Here is the formula that computes the -4 assuming M1 is 7/2018, M2 is 26, H1 is 2/2018, H2 is 30 and we want to compare column M to column H since today is in July and we want to compare July to February (5 months difference):
=INDIRECT("R2C"&MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0),FALSE)-INDIRECT("R2C"&MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0)-5,FALSE)
This is an array function so it needs to be entered with [Ctrl]+[Shift]+[Enter].
The way it works is that it computes from today's date, the date value equal to the first day of this month. Then it compares that against the range A1:R1 with each of those dates likewise moved to the first of the month. This gives us the column to use for "this month" and using the same computation but subtracting 5 gives us the column to use for "six months ago." Out of sheer laziness I used these values in an indirect cell reference to pull the Row 2 values for "this month" and "six months ago" and subtracted the latter from the former (i.e., "this month" - "six months ago").
In other words, this part of the formula gives me the column of the current month:
MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0)
and this part gives me the column of the month six months ago (as defined in the original post):
MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0)-5
As I indicated, this may not be what you wanted, but this is what I thought you were asking.
Alternate version using INDEX function
=INDEX(A2:R2,MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0))-INDEX(A2:R2,MATCH(DATE(YEAR(TODAY()),MONTH(TODAY()),1),DATE(YEAR(A1:R1),MONTH(A1:R1),1),0)-5)
The above would also be entered as an array formula.

Calculating Based on an Array in Excel

I have a Pivot Table that I am able to cycle through the different months based on a Month Filter (changing the data of the table). I am trying to calculate based off of that change of value. I am recording the amount of times a license is used in a workday. The number of workdays in a month change based on the month. I calculated out the workdays for each month using
=NETWORKDAYS(H34,EOMONTH(H34,0),J34:J45)
H34 references my 1/1/2016 date. J34:J45 references my holiday dates to avoid.
I am trying to write a formula that says "If the month listed (from my month filter) within the Months list then to print the corresponding Workdays value.
=IF(G34:G46=H48, I34:I46)
It only works on January. The rest of the values return False. I do calculate it as an Array Function. It returns either False. I cannot think of another function that could replace it. Any help would be appreciated.
2016
Month Date Workdays Holiday Dates Holidays
January 1/1/2016 19 1/1/2016 New Year's day
February 2/1/2016 20 18-Jan Holiday 2
March 3/1/2016 22 2/15/2016 Valentines day
April 4/1/2016 21 3/25/2016 St. Patrick's Day
May 5/1/2016 21 5/30/2016 Memorial Day
June 6/1/2016 22 7/4/2016 Independence Day
July 7/1/2016 21 9/5/2016 Labor Day
August 8/1/2016 23 10/10/2016 Holiday
September 9/1/2016 22 11/8/2016 Columbus Day
October 10/1/2016 21 11/11/2016 Veteran's Day
November 11/1/2016 21 11/24/2016 Thanksgiving
December 12/1/2016 21 12/26/2016 Christmas
All 235
Selected Month
March FALSE
The VLOOKUP() function will greatly simplify this process for you. This particular function is great for extracting values in a list based on a key lookup field.
In your example, you want to easily extract the value from Holiday Dates column based on an input month.
A few things to keep in mind for the input parameter functions in this function:
The first column in your table array must contain the lookup value, in this case, the month column.
If may need to lock your array dimensions, use the $ sign in front of the column letter and row number.
FALSE should be selected for the range_lookup in order to do exact matching for the lookup value. If you choose false, you may get false positivies.
Every row in your list should be unique for the lookup value. Let's say January was listed twice, the value returned would be for the first occurrence.
Additional info:
http://spreadsheeto.com/vlookup/
http://www.howtogeek.com/howto/13780/using-vlookup-in-excel/
You can use the LOOKUP function, as follow:
=VLOOKUP(G48,G34:I45,3)
This formula looks up "G48" value in column G (first matrix column), and returns the value from column I (third matrix column) that is in the same row.
Read this official Office page for more details.
Please, give us your feedback.

Find last digits with IF

I have lots of cells in the spreadsheet that contains the whole year, date and stock prices, but I only need the dates from 25th of the last month till the 5th of this month.How can I write a function to do that? For example if the cells are like this in the column:
19900101
19900102
19900103
19900104
19900105
.
.
19900125
19900126
19900127
19900128
19900129
19900130
19900131
I want it to show only days (1,2,3,4,5,25,26,27,28,29,30,31) with the date format.
The date shows in the text format and I've tried format cell to change it but it doesn't work.
For a slightly different approach, assuming you want to return the A2 value only if it represents a date in the last 5 or first 5 days of any month you can use this formula in B2
=IF(DAY(TEXT(A2,"0000-00-00")+5)<11,A2,"")
TEXT function converts your data to a real date then if you add 5 days to that date then any date that was originally in the last 5 or first 5 of the month will now be in the first 10 days of the month.....so it's sufficient to check that the day is < 11. That will pick up 27th to 31st of a 31 day month, 26th to 30th of a 30 day month etc.
you could use a formula and then filter by rows with data...
As an example (given it's difficult to discern if you always want the first 5 and last 5 of a month or what....)
=IF(RIGHT(A2,2)*1<=2,A2,IF(RIGHT(A2,2)*1>=29,A2,""))
Based on all the edits and comments, these should be the function you need.
=IF(OR(A7-A2>5,MOD(A2,100)<=5),DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2)),"")
You should place it in cell B2 and then do all the desired filtering, as explained in xQbert's answer.

Resources