+ Reply to Thread
Results 1 to 4 of 4

Calculations based on segments in a table

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Calculations based on segments in a table

    I have attached a workbook which contains a sample trade history. Interspersed between trades are deposits and withdrawals. I want to sum up the profit/loss between these deposits/withdrawals and then obtain a % profit/loss based on the account balance at the time of the previous deposit/withdrawal.

    Then I want to sum up the total of each of the above calculations on a monthly basis.

    The attached workbook provides the desired outcome, along with clarifying comments.

    Any advice? Thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Calculations based on segments in a table

    Hi, I have not the complete solution, but you can start with this:
    to copy down from K4 and L4:
    Please Login or Register  to view this content.
    For the totalling of months you can copy this down from M4:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    Last edited by Eastw00d; 04-28-2020 at 12:30 AM. Reason: additional information
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Calculations based on segments in a table

    Please try at
    K4
    =IF((LEN(E4)<5)*((LEN(E5)>5)+(MONTH(B4)<>MONTH(B5))),SUM(INDEX(F$3:F4,MATCH(2,1/((LEN(E$2:E3)>5)+(MONTH(B$2:B3)<>MONTH(B4))))):H4),"")

    L4
    =IF(K4="","",K4/LOOKUP(2,1/(LEN(E$2:E3)>5),I$2:I3))

    M4
    =IF(MONTH(B4)<>MONTH(B5),SUM(INDEX(L$3:L4,MATCH(2,1/(MONTH(B$2:B3)<>MONTH(B4)))):L4),"")
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: Calculations based on segments in a table

    Thanks! I appreciate your help. I had started a solution which involved lots of helper columns but your solution is much more elegant.
    Last edited by jrtaylor; 04-28-2020 at 10:30 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Coloring Radar Chart based on categories and segments
    By brissyb in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-03-2018, 04:45 AM
  2. Replies: 1
    Last Post: 03-23-2017, 03:53 PM
  3. Create a four-column sorting table that updates based on calculations.
    By arwebb0264 in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-13-2016, 03:38 PM
  4. only showing segments of pivot table
    By ammartino44 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 09-10-2014, 05:22 PM
  5. Replies: 3
    Last Post: 08-16-2012, 11:22 AM
  6. Replies: 3
    Last Post: 03-04-2010, 01:11 PM
  7. get Pivot table calculations
    By jeamsu in forum Excel General
    Replies: 1
    Last Post: 07-06-2007, 02:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1