Assume a five column dataset with the Fund Name in column A, Market Value in column B, Gain/Loss in column C, Gain/Loss % in column D [column C/column B] and Type of investment in column E (Short term or Long term). Since multiple investments can be made in one fund, there can be multiple line items for with the same Fund Name (with different market values). Let's call this dataset the Investment schedule.
The objective is to determine the following:
a. Minimum total gain realised from sale of one/multiple funds; and
b. Short term gain present in a above; and
c. Total Long term gain realised from sale of one/multiple funds; and
d. If Long term investments fall for liquidating the particular fund, then how much is the gain/loss by forcible liquidating the short term investments.
You may refer to my solution in this workbook.