• Chris,
    Dates are not consecutive. This script transform transactional data into a register. Initial data is contained in two different tables. One contains percentages while the other contains values that will be used to calculate percentages. Initial data may look like:

    table1:
    2001-01-01, Me, 100%
    2001-01-05, Me, 50%
    2001-01-05, You 50%
    2001-01-10, You 100%
    table2:
    2001-01-20, Me, +100 //From this point on, we calculate the percentages. I own 100 out of 100
    2001-01-21,You, +100 //I own 100 out of 200 and you own 100 out of 200

    And reportable result would be

    Me, from 2001-01-01 to 2001-01-05, 100%
    Me, from 2001-01-05 to 2001-01-10, 50%
    Me, from 2001-01-20 to 2001-01-21, 100%
    Me, from 2001-01-21, 50%
    You, from 2001-01-05 to 2001-01-10, 50%
    You, from 2001-01-10 to 2001-01-20, 100%
    You, from 2001-01-21, 50%

    Producing the result requires several steps and my issue was related to one of these steps.