Calculating Based on an Array in Excel - 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.

Related

How to get week number based on Two dates based Conditions in Excel

I have a DateTime column in Excel in which data is sorted in ascending order based on DateTime conditions from 15th June to say 1st November ;
I want to print Week Number from 1st to Nth Week based on date condition; Week criteria are like first seven days i.e 15th June to 21st June is Week1, 22nd Jun-28th Jun is Week2, 29th June - 5th June is Week3 and so on.
How Can I do this?
Column1
06/15/2021 8:00
06/15/2021 10:00
:
:
11/01/2021 20:44
11/01/2021 20:46
Let's assume your list of dates is in A2:A.
Place the following formula in cell B2 of an otherwise empty range B2:B...
=ArrayFormula(IF(A2:A="",,ROUNDDOWN((INT(A2:A)-INT(A2))/7)+1))
INT is just removing the times from date-times.
The rest is really more of a math/logic question than a formula question.

Find first date after today that matches a day-number and weekday

Given any date, how do I find the first month and year in the future where the 31st of that month falls on a Wednesday, in other words, for today, 11 November 2020, I would like to see (31) March 2021. [Updated: Returned month should be March 2021]
#prino,
You could make use of Excel's Iterative Calculation, setting Maximum Iterations to 1000.
In the example below, A1 is the given date and B1 receives the result (put the formula in B1):
=IF(B1=0,A1)+B1+IF(AND(WEEKDAY(B1,1)=4,DAY(B1)=31),0,1)
If you have Excel 365 then
=LET(DayInMonth, DATE(YEAR($A$2),MONTH($A$2)+SEQUENCE(336,,0,1),$B$2),
DOW, WEEKDAY(DayInMonth),
IsMatch, (DAY(DayInMonth)=$B$2)*(DOW=$C$2)*(DayInMonth>=$A$2),
XLOOKUP(1,IsMatch,DayInMonth,,0,1))
How it works:
Parameters are on the sheet (you could hard code these into the formula if you wish)
A2 is the start date (could be formula =TODAY())
B2 is the day number in the month
C2 is the day of week code (1..7 = Sunday..Saturday)
The calander repeats every 28 years. So only need to consider 12*28 = 336 months
DayInMonth is the specified date in each of the next 336 months, including this month. Note: if a month does not have the specified day (eg 31 September does'nt exist)
DOW is the day of Week code for those dates
IsMatch is 1 if calculated DayInMonth matches specified DayInMonth (this excluded non-existant dates) AND Calculated DOW matches specified DOW AND calculated date is on or after start date
XLOOKUP returns the date of the first 1 in the IsMatch array

List yearly, monthly, quarterly, biweekly dates interval in a column through excel formula

I have the table below.
In the first column, I placed the periods (or the number of instances; it works like an ID in this table). The table is named "LoanSchedule".
$B$20 stores a date. In this case, I entered February 20, 2020.
I have this formula in Column 2 to list the consecutive monthly date after $B$20.
$B$18 stores the number of times payment is made in a year
=IF(AND([#[Payment Period]]<>"",$B$20<>"--"),IF($B$18=12,EOMONTH($B$20,ROW([#[Payment Period]])-ROW(LoanSchedule[[#Headers],[Payment Period]])-1)+DAY($B$20),"--"))
It works well if payment is monthly or $B$18 = 12.
How can I modify the formula if Payment periods will be quarterly(4x year), yearly, or biweekly (26weeks), and list the corresponding months?
For example if I choose quarterly & $B$20 stays the same, the dates that will be displayed on the second column will be May 20, 2020; August 20, 2020, November 20, 2020, February 20, 2021, etc. if Biweekly, every 2 weeks. Thanks for any help.
You need to translate the entries in B18 (number of pmts per year), and the payment period, into the number of months or days to add to the original date.
I translated {1,4,12} using a lookup table with vlookup, handling 26 separately for the 14 day interval (2 weeks).
I chose this method because merely dividing 12/$B$18 would require a more complex formula should the result of the division not be an integer, since payments would then not be at monthly intervals
=IF($B$18=26,$B$20+14*[#[Payment Period]],
EDATE($B$20,VLOOKUP($B$18,{1,12;4,3;12,1},2,FALSE)*[#[Payment Period]]))
B18 = 12
B18=4
B18=26

How to collect number of days from a month in excel

I have a column which will have some days from a month in dd-mm-yyyy format. What I need to get total number of days from each month mentioned in that column. The column might not contain all days from each month.
Example :
Column A :
2017-01-01
2017-01-02
2017-01-17
2017-01-27
2017-02-08
In above example, from 2017 Jan, I have 4 days and from Feb I have one day. I need this count for a IF statement to run in C column. ie, in C1 there will be an IF function which will check the month in A1 and count the total number of days for that specific month from A column. If that count is below a specific digit, I need to perform a formula otherwise a different one. This will repeat for all C cell
If this column contains all date from each month I can use Day function to get total days, but here how Can I collect it
This will work: =SUMPRODUCT(1*(MONTH($A1:$A5)=D1))
And an example of manipulating basing on the result:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=D1))<3;"good";"bad")
Another one when row number represents a month (JAN in C1, FEB in C2...):
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<3;"good";"bad")
In your case:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<10;function1();function2())
Array formula - use Ctrl+Shift+Enter:
=SUM((MONTH($A$1:$A$5)=MONTH(A1))*(YEAR($A$1:$A$5)=YEAR(A1)))

Google Spreadsheet: Find the largest number within a date range

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)

Resources