Create an area chart from stock values

stefanaalten

Board Regular
Joined
Feb 1, 2011
Messages
74
Office Version
  1. 365
Platform
  1. Windows
Hope the MrExcel community is feeling clever 'cos I'm not! 🤔 I'd appreciate some help with this "simple" question! Oh, and Best Wishes for 2025.

I have data representing stocks: stock name, units held, price, value, cost, gain/loss, date (as at).

I can't modify the source data - it comes pre-supplied (daily download), so I just copy the values (insert rows) into a summary spreadsheet, as shown below (simplified example).

My question consists of two parts - hope that's okay.

1) I'd like to have a pivot table that shows at a glance how stocks have performed. As can be seen below, the data I have already provides "total as at date" (e.g. value) but the ÎŁ Values panel insists of applying a formula ("Summarize value field by"), "sum" by default, which is not what I want. Is there a a way of saying "just show the data as is - no need to "summarize"? Hope I've explained that okay.

2) Then, and this is my main question really, I would like to produce an area chart (or something similar) that shows how each stock has contributed to the total, i.e. time along the horizontal, axis, ÂŁ along the vertical, and each "area" representing a different stock (in different colour for each).

I will have new data to add every day, i.e. another lot of stocks (these may vary over time).

Any help very much appreciated! :-)

Here's my data
Account Summary (to illustrate question).xlsx
ABCDEFGH
1StockUnits heldPrice (pence)Value (ÂŁ)Cost (ÂŁ)Gain/loss (ÂŁ)Gain/loss (%)As at (date2)
2Stock A1,282.36385.374,941.814,855.1686.651.782024-12-12
3Stock A1,282.36385.664,945.534,855.1690.371.862024-12-13
4Stock A1,282.36385.834,947.714,855.1692.551.912024-12-17
5Stock A1,282.36385.514,943.614,855.1688.451.822024-12-18
6Stock A1,282.36384.554,931.304,855.1676.141.572024-12-20
7Stock A1,282.36385.194,939.504,855.1684.341.742024-12-27
8Stock A1,282.36385.594,944.634,855.1689.471.842025-01-01
9Stock B680.392404.2816,358.4616,250.00108.460.672024-12-12
10Stock B680.392397.3416,311.2416,250.0061.240.382024-12-13
11Stock B680.392378.7416,184.6916,250.00-65.31-0.402024-12-17
12Stock B680.392353.8816,015.5416,250.00-234.46-1.442024-12-18
13Stock B680.392315.1115,751.7516,250.00-498.25-3.072024-12-20
14Stock B680.392335.6615,891.5716,250.00-358.43-2.212024-12-27
15Stock B680.392335.4115,889.8716,250.00-360.13-2.222025-01-01
16Stock C7,041.41209.2614,734.8514,625.00109.850.752024-12-12
17Stock C7,041.41209.6214,760.2014,625.00135.200.922024-12-13
18Stock C7,041.41209.3414,740.4814,625.00115.480.792024-12-17
19Stock C7,041.41209.1514,727.1014,625.00102.100.702024-12-18
20Stock C7,041.41207.7514,628.5214,625.003.520.022024-12-20
21Stock C7,041.41207.7314,627.1114,625.002.110.012024-12-27
22Stock C7,041.41208.2514,663.7314,625.0038.730.262025-01-01
23Stock D3,984.78264.9010,555.699,950.00605.696.092024-12-12
24Stock D3,984.78265.8010,591.559,950.00641.556.452024-12-13
25Stock D3,984.78265.6010,583.589,950.00633.586.372024-12-17
26Stock D3,984.78264.1010,523.819,950.00573.815.772024-12-18
27Stock D3,984.78258.6010,304.659,950.00354.653.562024-12-20
28Stock D3,984.78263.7010,507.879,950.00557.875.612024-12-27
29Stock D3,984.78261.7010,428.179,854.62573.555.822025-01-01
30Stock E436.001809.207,888.118,126.30-238.19-2.932024-12-12
31Stock E436.001730.607,545.428,126.30-580.88-7.152024-12-13
32Stock E436.001661.407,243.708,126.30-882.60-10.862024-12-17
33Stock E436.001644.207,168.718,126.30-957.59-11.782024-12-18
34Stock E436.001645.207,173.078,126.30-953.23-11.732024-12-20
35Stock E436.001628.807,101.578,126.30-1,024.73-12.612024-12-27
36Stock E436.001633.207,120.758,126.30-1,005.55-12.372025-01-01
37Stock F231.003586.508,284.828,118.20166.622.052024-12-12
38Stock F231.003630.508,386.468,118.20268.263.302024-12-13
39Stock F231.003578.508,266.348,118.20148.141.822024-12-17
40Stock F231.003551.008,202.818,118.2084.611.042024-12-18
41Stock F231.003525.008,142.758,118.2024.550.302024-12-20
42Stock F231.003487.508,056.138,118.20-62.07-0.762024-12-27
43Stock F231.003489.508,060.758,118.20-57.45-0.712025-01-01
44Stock G7,701.42185.6014,293.8414,625.00-331.16-2.262024-12-12
45Stock G7,701.42185.6014,293.8414,625.00-331.16-2.262024-12-13
46Stock G7,701.42185.2014,263.0314,625.00-361.97-2.482024-12-17
47Stock G7,701.42182.6014,062.8014,625.00-562.20-3.842024-12-18
48Stock G7,701.42180.5013,901.0714,625.00-723.93-4.952024-12-20
49Stock G7,701.42182.8014,078.2014,625.00-546.80-3.742024-12-27
50Stock G7,701.42183.3014,116.7114,625.00-508.29-3.482025-01-01
Sheet1
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Here is a sample worksheet I use to track stock gains and losses. I've been using this method for over 20 years. Note that using this system requires a different sheet for each stock. I then summarize using vlookup on a separate page.

Sample Purchase and Sale.xlsx
ABCDEFGHIJKLMNOPQR
1Stocl Performance AnalyzerAmount
2Menu!A1FALSE
3******** Transaction ******** ******** Tax Ledger ******** ************ Market Value ************ ********** Return on Investment **********
4ABC CompanyFundAnnualized
5ABCNumberCostNumberAverageMarketOutsideAssets +Return onAnnualized
6ofPerofTaxCostPerGain orAssetsCashInitialPeriodic
7DateTransactionSharesShareAmountSharesCostPer ShrDateShareTotal(Loss)InvestedWithdrawalsInvestmentReturn
8
912/24/2015Purchase12,537.598$15.7100$ 196,965.6712537.5980$196,965.67$15.71012/24/15$15.710$196,965.67$0.00$196,965.67$196,965.67
1012/31/2015Div Reinvest1.011$15.7200$ 15.9012538.6090$196,981.57$15.71012/31/15$15.720$197,106.93$141.26$196,965.67$197,106.933.81%3.81%
111/29/2016Purchase1,000.000$15.7800$ 15,780.0013538.6090$212,761.57$15.71501/29/16$15.780$213,639.25$893.58$212,745.67$213,639.254.70%4.91%
123/1/2016Sale(500.000)$15.8100$ (7,905.00)13038.6090$204,903.98$15.71503/01/16$15.810$206,140.41($6,605.26)$212,745.67$206,140.41-16.73%-33.47%
134/1/2016Div Reinvest4.365$15.7600$ 68.8013042.9740$204,972.78$15.71504/01/16$15.760$205,557.27($7,188.40)$212,745.67$205,557.27-12.81%-3.28%
Sheet1
Cell Formulas
RangeFormula
R2R2=E9<0
D9D9=E9/C9
F9F9=C9
G9G9=E9
H9:H13H9=G9/F9
M9,I9:I13I9=A9
J9:J13J9=D9
K9:K13K9=F9*J9
L9:L13L9=N9-M9
N9:N13N9=K9-DSUM(E$8:E9,(0+1),R$1:R$2)
F10:F13F10=IF(CELL("contents",B10:B10)="Dividend",F9,F9+C10)
G10:G13G10=IF(CELL("contents",B10:B10)="Dividend",G9,IF(CELL("contents",B10:B10)="Sale",F10*H9,G9+E10))
M10:M13M10=IF(CELL("contents",B10:B10)="Purchase",M9+E10,M9)
O10:O13O10=((IF(M10>M$9,N10-(M10-M$9),N10)/M$9)^(1/((I10-I$9)/365)))-1
P10:P13P10=((IF(M10>M9,N10-(M10-M9),N10)/N9)^(1/((I10-I9)/365)))-1
E11:E12E11=C11*D11
 
Upvote 0
Many thanks Alan! However, all I really want to do is to create a chart to show how the stocks have performed over time, using the data in the format already available in the download, with minimal manipulation. It's all there as far as I can see - the stock name, the value (or the gain/loss), and the date of th report. I envisage a chart which has dates along the horizontal, ÂŁ along the vertical axis and then a filled area to reflect the stock value. Like this image (illustration only - the data does not correspond with my example). However, when I select the data and "insert chart" I can't seem to get anything like the illustration shown below. Any ideas/help very much appreciated!
stacked-area-chart-excel.png
 
Upvote 0
Looks like my brain still has some uses ... I managed to work out a solution and yes, it was simple, once I'd realised it! :ROFLMAO:

Here's what I did ...

1) Created pivot table with As at date in the Rows panel, Stock in the Columns panel, and Sum of Value in the ÎŁ Values panel (there is only ever a single value for a given stock on a given date so that works). That gave me a table like this:
Account Summary (to illustrate question).xlsx
ABCD
3Sum of Value (ÂŁ)Column Labels
4Row LabelsStock AStock BStock C
52024-12-124,941.8116,358.4614,734.85
62024-12-134,945.5316,311.2414,760.20
72024-12-174,947.7116,184.6914,740.48
82024-12-184,943.6116,015.5414,727.10
92024-12-204,931.3015,751.7514,628.52
102024-12-274,939.5015,891.5714,627.11
112025-01-014,944.6315,889.8714,663.73
Sheet2


2) Clicked the PivotChart icon, selected Stacked Area as chart type and hey presto ...

1735849980350.png


In the simplified example there are only three stocks and seven "as at" dates but I have done this to my actual data which includes 30 stocks and more dates and it looks very legible - just what I was after with a minimum of fuss, yay!
 
Upvote 0
Solution

Forum statistics

Threads
1,225,204
Messages
6,183,581
Members
453,172
Latest member
dreximgirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top