Calculate latest quarter end

dgabor

New Member
Joined
Apr 17, 2020
Messages
1
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
Hi All,

In an older thread I have seen the below solution for calculating the latest quarter end from a given date and it seems to work. However, I am not sure how the formula works.

Could you please explain?

=LOOKUP(B1,DATE(YEAR(B1),{1,4,7,10},0))

Thank you!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Welcome to the forum!

The array constant {1,4,7,10} has the month numbers of January, April, July, and October. When you enter multiple values in an array that usually has 1, Excel will calculate all the values. So DATE will calculate all 4 of these:

DATE(YEAR(B1),1,0)
DATE(YEAR(B1),4,0)
DATE(YEAR(B1),7,0)
DATE(YEAR(B1),10,0)

The day value in DATE is 0 for all four cases, so it calculates the day before if you used 1, or the last day of the previous month. So you'll end up with an array holding the 4 end days of the quarters:

12,31,year-1
3,31,year
6,30,year
9,30,year

Then finally LOOKUP takes the date in B1, and searches for the highest value in that list that is less than B1, which gives you the date you want.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top