Formula to find last date of a given MONTH and return value from another cell on the same row

UpToTheGills

New Member
Joined
Aug 26, 2022
Messages
38
Office Version
  1. 2019
Platform
  1. MacOS
Been trying without success to nail this one.

I have a summary page on one worksheet where I want to calculate the percentage gain (or loss) for an account against the previous month (cell H6), where the data is in a table on another worksheet.
IC Live 260051267 - Trading Journal.xlsm
CDEFGH
3Month / YearGain on A/c
4
5Aug 2023$1,393.3746.4%
6Sep 2023$1,551.60297000.0%
Stats Overview
Cell Formulas
RangeFormula
F5:F6F5=IF(TODAY()<D5,"",SUMIFS(ENTRIES[Net P&L (£)],ENTRIES[Broker Exit Time],">="&D5,ENTRIES[Broker Exit Time],"<"&EDATE(D5,1)))
H5H5=F5/3000
H6H6=VLOOKUP(MAX(EOMONTH(D5,0)),ENTRIES[[Broker Exit Time]:[A/c Balance]],22,TRUE)


and I just cannot figure out the correct syntax to make it work.

My thinking in the formula I've used, is to reference the previous month, cell D5, use EOMONTH to return 31-Aug-23, then use MAX to find the last August date that occurs in the ENTRIES table (which won't necessarily be the 31-Aug-23) to then return the corresponding value from the A/c Balance table column in the same row.

Not sure if it is relevant but I insert new lines at the top of the ENTRIES table, so rows are sorted from newest to oldest and also have the times in the same cells, formatted DD-MMM hh:mm.

Thank you for any help.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Excel Formula:
=MAXIFS(ENTRIES[[A/c Balance],ENTRIES[[Broker Exit Time],">="&D5,ENTRIES[[Broker Exit Time],"<"&EDATE(D5,1))

Feel I'm nearly there with this one but this is returning the largest value in the A/c Balance column in August but I want the formula to return the value of A/c Balance for the last occurrence of an August date.
 
Upvote 0
Need to double-check but I believe I may have nailed it with this formula:
Excel Formula:
=IF(TODAY()<D6,"",F6/VLOOKUP(MAXIFS(ENTRIES[Broker Exit Time],ENTRIES[Broker Exit Time],">="&D5,ENTRIES[Broker Exit Time],"<"&EDATE(D5,1)),ENTRIES[[Broker Exit Time]:[A/c Balance]],22,FALSE))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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