Find closing price in stock exchange transactions

hlombard

New Member
Joined
Apr 17, 2014
Messages
3
I have a (powerpivot) table with the following fields from transactions on a stock exchange:


  1. Sequence number
  2. DateTime of transaction
  3. Price at which the trade occured

I need to add a Calculated Column (not a Measure) that shows the closing price for each day (on every row).

So for each day it should return the Price of the last trade on that day.

Your help is appreciated!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try this:

- Create an additional column which is just the date (no time) called Date. You could use ROUNDDOWN(Datetime,0).

- Write the measure that returns a table made up of the top/highest DateTime to find the corresponding value: =CALCULATE(MAX([Price]),TOPN(1, FILTER(Table1,[Date]=EARLIER([Date])),1))

Hope this helps.
 
Upvote 0
Thanks for your quick response!

I tried it and it almost works.

Instead of returning the last price on the day it returns the highest price for the day.
I think it is the Max(price) that causes that.

How can I return the price of the Max(Sequence no) ?
The highest sequence number on the day is also the last price of the day.
 
Upvote 0
Sorry, messed up the final argument of the TOPN! Try this:

Code:
=CALCULATE(MAX([Price]),TOPN(1, FILTER(Table1, table1[Date]=EARLIER(table1[Date])),Table1[Sequence]))
 
Upvote 0

Forum statistics

Threads
1,223,992
Messages
6,175,823
Members
452,672
Latest member
missbanana

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