Forum

Notifications
Clear all

Grouped running balances & average cost, Gain& Loss

9 Posts
2 Users
0 Reactions
85 Views
(@arun-kainthgmail-com)
Posts: 9
Active Member
Topic starter
 

Hi,

Can anyone help to write formulas to automatically calculate grouped running calculations to fill columns H, I and J. I have attached file to with notes. Thanks

 
Posted : 24/03/2021 11:35 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Aarun,

You can use SUMIFS for these calculations. See file attached.

Mynda

 
Posted : 25/03/2021 12:17 am
(@arun-kainthgmail-com)
Posts: 9
Active Member
Topic starter
 

Hi Mynda,

Thanks for your quick response always.

Sorry for delayed reply.

Yes your SUMIFS did the job to Balance Qty but didn't gave desired results for other two when I compare with my manual calculation done for ticker GME. I am uploading workbook again with more worksheet named Adjusted Cost Basis. Also I have added one more column H to Ledger worksheet which can be calculated same as in Adjusted Cost Basis sheet. 

I think formula need some function which should use old date first. 

I tried to use XLOOKUP after I watched your vide which gives some option to use dates but still a puzzle for me to get results for my needs.

Your further help will be greatly appreciated. 

Thank you,

 

Aarun 

 
Posted : 26/03/2021 11:18 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Aarun,

The formula does use the old date first because the data is sorted by the 'Symbol' and then the 'Date& time' column in ascending order. I see some hard keyed values in columns M:N of the ledger, but you haven't explained how these were calculated, so they don't help me understand what you're expecting to see.

The dates in the Adjusted Cost Basis sheet for the GME transactions are different to the dates in your ledger. Perhaps this is the problem.

Mynda

 
Posted : 27/03/2021 4:27 am
(@arun-kainthgmail-com)
Posts: 9
Active Member
Topic starter
 

Hi Mynda,

Hope you had a great weekend.

I fixed the data now, please help to calculate now col J K L for table ACB so it gives results as per table below on row 30.

Please add commission amount in also for Col K & L

 

I tried and learned to write simple SUMIFS in Col PQRS but have 2 questions;

  1.  Why my formula is adding table name whereas your doesn't?  When I tried to remove table name it gives error. Your formulas are in Green and mine in Orange on rows 25 - 30.  
  2.  How to add commission amount in Col R & S ?

Thank you. 

Arun 

 
Posted : 30/03/2021 1:09 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Arun, 

No file uploaded. Please click the 'start upload' button after selecting your file and then wait for the message in green below the attachment box to let you know it has completed uploading.

Mynda

 
Posted : 30/03/2021 7:26 am
(@arun-kainthgmail-com)
Posts: 9
Active Member
Topic starter
 

Hi Mynda,

 

Sorry I couldn't recognize that didn't got uploaded properly; but now attached. 

Arun 

 
Posted : 30/03/2021 8:12 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Arun,

Thanks for clarifying. Some of these calculations are not designed to be performed in a table that contains different symbols. If you look at the formulas in columns I and J of your GME table (starting on row 31) you'll notice that the formulas are different for the first row (row 33) than they are for the rest of the rows in the table. It's for this reason that you cannot have one formula in a table that contains multiple different symbols. Tables are designed to have the same formula in every row. 

On top of that there is some ambiguity e.g. 150 AMC shares are purchased, then 129 are sold, then a further 133 are purchased. How does Excel know which price to apply to which bundle of shares sold. It's a messy conundrum and you need to be very clear on the logic you want applied.

In the attached file I've added a column for 'Batch'. This allows you to group the shares into bought & sold batches. When you sell part of a batch you must split that transaction out into two rows, one containing the number of shares sold and one containing the balance of shares still held. You'll see I've done this with AMC purchased and sold on 9th March.

These batch numbers allow you to group the data into like bundles for the purpose of calculating the average cost and gain/loss in columns K & L. See file attached.

To answer your question about the table name: when a formula is inside a table the name of the table isn't necessary as it is inferred that the formula is referencing a column in the current table. However, if your formula is outside of the table then you must explicitly reference the table name and column so Excel knows which table you're referring to.

Mynda

 
Posted : 31/03/2021 3:02 am
(@arun-kainthgmail-com)
Posts: 9
Active Member
Topic starter
 

Sorry for delayed reply.

Thank you very much Mynda for all your time & help in the matter. This should help. 

Once again, truly appreciate what you are doing for all; especially novices. 

I will definitely come back here next time whenever help is needed. 

Arun 

 
Posted : 07/04/2021 8:34 am
Share: