Formula to get last value of month

Greg123

New Member
Joined
Apr 8, 2019
Messages
4
I have a worksheet like this one. I am looking for a formula that will return the last production number for each month into the table on the right. However, not every date is listed so the formula can not simply look for the last day of the month (e.g. 3/31/19) because that date might not be listed at all. Any help is appreciated!

ABCDEFG
1DateDayProductionMonthProduction
201/02/19WedJan
301/04/19Fri38,891Feb
401/15/19TueMar
501/16/19WedApr
601/17/19Thu90,572May
701/23/19WedJun
801/24/19Thu147,728Jul
901/31/19Thu35,279Aug
1002/01/19FriSep
1102/04/19MonOct
1202/05/19Tue28,165Nov
1302/14/19Thu44,083Dec
1402/22/19Fri
1502/25/19Mon28,545
1602/26/19Tue5,329
1702/27/19Wed
1802/28/19Thu
1903/01/19Fri19,410
2003/04/19Mon55,347
2103/25/19Mon72,419
2203/26/19Tue14,509
2303/28/19Thu
2403/29/19Fri
2504/01/19Mon12,539
2604/02/19Tue44,113
2704/03/19Wed
2804/04/19Thu
2904/05/19Fri37,608
3004/08/19Mon38,097
31

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Maybe something like this:
This is an array formula and must be entered with CTRL-SHIFT-ENTER. Then drag formula down.
Excel Workbook
ABCDEFG
1DateDayProductionMonthProduction
21/2/2019WedJan35,279
31/4/2019Fri38,891Feb5,329
41/15/2019TueMar14,509
51/16/2019WedApr38,097
61/17/2019Thu90,572May
71/23/2019WedJun
81/24/2019Thu147,728Jul
91/31/2019Thu35,279Aug
102/1/2019FriSep
112/4/2019MonOct
122/5/2019Tue28,165Nov
132/14/2019Thu44,083Dec
142/22/2019Fri
152/25/2019Mon28,545
162/26/2019Tue5,329
172/27/2019Wed
182/28/2019Thu
193/1/2019Fri19,410
203/4/2019Mon55,347
213/25/2019Mon72,419
223/26/2019Tue14,509
233/28/2019Thu
243/29/2019Fri
254/1/2019Mon12,539
264/2/2019Tue44,113
274/3/2019Wed
284/4/2019Thu
294/5/2019Fri37,608
304/8/2019Mon38,097
Sheet
 
Upvote 0
alternative with PowerQuery (Get&Transform)

DateDayProductionMonth NameProduction
02/01/2019​
WedJanuary
35279​
04/01/2019​
Fri
38,891​
February
5329​
15/01/2019​
TueMarch
14509​
16/01/2019​
WedApril
38097​
17/01/2019​
Thu
90,572​
23/01/2019​
Wed
24/01/2019​
Thu
147,728​
31/01/2019​
Thu
35,279​
01/02/2019​
Fri
04/02/2019​
Mon
05/02/2019​
Tue
28,165​
14/02/2019​
Thu
44,083​
22/02/2019​
Fri
25/02/2019​
Mon
28,545​
26/02/2019​
Tue
5,329​
27/02/2019​
Wed
28/02/2019​
Thu
01/03/2019​
Fri
19,410​
04/03/2019​
Mon
55,347​
25/03/2019​
Mon
72,419​
26/03/2019​
Tue
14,509​
28/03/2019​
Thu
29/03/2019​
Fri
01/04/2019​
Mon
12,539​
02/04/2019​
Tue
44,113​
03/04/2019​
Wed
04/04/2019​
Thu
05/04/2019​
Fri
37,608​
08/04/2019​
Mon
38,097​

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Month = Table.AddColumn(Table.TransformColumnTypes(Source,{{"Date", type date}, {"Day", type text}, {"Production", Int64.Type}}), "Month Name", each Date.MonthName([Date]), type text),
    Group = Table.Group(Table.SelectRows(Month, each ([Production] <> null)), {"Month Name"}, {{"Max", each List.Max([Date]), type date}, {"Count", each _, type table}}),
    Expand = Table.ExpandTableColumn(Table.AddColumn(Group, "Custom", each Table.LastN([Count],1)), "Custom", {"Production"}, {"Production"}),
    ROC = Table.RemoveColumns(Expand,{"Count", "Max"})
in
    ROC[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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