Which formula of sum product should I put in the column C cells to calculate the cost basis of shares, which ignores the empty cells in column B and so considers only the prices in column A by which the quantity in column B is entered?
I tried to use the following formula, but it gives me the wrong result 1 instead of the right result 1,2712:
=SUMMENPRODUKT((A$2:A$30)*(B$2:B$30<>""))/SUMMEWENN(B2:B30;">0";A2:A30)
Whit the desired formula:
If I enter the first quantity 1 in cell B1, should appear the cost basis 1,2725 in cell C2
If I enter the second quantity 3 in cell B8, should appear the cost basis 1,2721 in cell C8
If I enter the third quantity 4 in cell B17, should appear the cost basis 1,2712 in cell C17
I tried to use the following formula, but it gives me the wrong result 1 instead of the right result 1,2712:
=SUMMENPRODUKT((A$2:A$30)*(B$2:B$30<>""))/SUMMEWENN(B2:B30;">0";A2:A30)
Whit the desired formula:
If I enter the first quantity 1 in cell B1, should appear the cost basis 1,2725 in cell C2
If I enter the second quantity 3 in cell B8, should appear the cost basis 1,2721 in cell C8
If I enter the third quantity 4 in cell B17, should appear the cost basis 1,2712 in cell C17
Mappe1 (version 2).xlsb | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Price | Number of Long Contracts | Cost Basis | |||||
2 | 1,2725 | 1 | 1,2725 | |||||
3 | 1,2724 | |||||||
4 | 1,2723 | |||||||
5 | 1,2722 | |||||||
6 | 1,2721 | |||||||
7 | 1,2720 | |||||||
8 | 1,2719 | 3 | 1,2721 | |||||
9 | 1,2718 | |||||||
10 | 1,2717 | |||||||
11 | 1,2716 | |||||||
12 | 1,2715 | |||||||
13 | 1,2714 | |||||||
14 | 1,2713 | |||||||
15 | 1,2712 | |||||||
16 | 1,2711 | |||||||
17 | 1,2710 | 4 | 1,000000 | 1,2712 | (right answer) | |||
18 | 1,2709 | |||||||
19 | 1,2708 | |||||||
20 | 1,2707 | |||||||
21 | 1,2706 | |||||||
22 | 1,2705 | |||||||
23 | 1,2704 | |||||||
24 | 1,2703 | |||||||
25 | 1,2702 | |||||||
26 | 1,2701 | |||||||
27 | 1,2700 | |||||||
Tabelle1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C2 | C2 | =A2*B2 |
C17 | C17 | =SUMPRODUCT((A$2:A$30)*(B$2:B$30<>""))/SUMIF(B2:B30,">0",A2:A30) |
A3:A27 | A3 | =A2-0.0001 |