I have over 20 years of daily closing prices for a given stock. How do i create a pivot table of month-end closes? Thanking you, in advance.
I have over 20 years of daily closing prices for a given stock. How do i create a pivot table of month-end closes? Thanking you, in advance.
Attached is a mocked up scenario. Column A is consecutive dates. Column B is Price. Column C is formula to find End of Month. Column D is formula to test if Column A equals Column C. Build pivot with the data in this format. See attached file
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
Thank you. The last trade date is not always the last day of the month. It is easy to find the last trade date in steps in excel, I was looking for a way to do it in a pivot table, in the same way you can find, say, the year high and year low. See attached.
Inspired by Alan's suggestion:
1. Add a column (I) to the data populated using: =MONTH(A3)<>MONTH(A4)
2. Use the new column as a filter for the pivot table.
Let us know if you have any questions.
Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.
Thank you all. As I said in my original post, this is easy in excel. See attached for an explicit description of my request. It appears it cannot be done in a pivot table alone without a helper column.
Hi,
If you add your Pivot Table to the data model then you can achieve what you want with the following measure:
Replace Range in the above with the name of your table.PHP Code:
SPY Close :=
VAR CurrentDate =
MAX ( Range[Date] )
VAR LatestDateinMonth =
CALCULATE (
MAX ( Range[Date] ),
FILTER (
ALL ( Range ),
Range[Date] > EOMONTH ( CurrentDate, -1 )
&& Range[Date] <= EOMONTH ( CurrentDate, 0 )
)
)
RETURN
CALCULATE ( MAX ( Range[SPY] ), Range[Date] = LatestDateinMonth )
Regards
Create Table1
Insert Pivot > check add this data to the data model
Power Pivot > New Measure
=MAXX(TOPN(1,Table1,[Date],DESC),[SPY])
THIS is it! Thank you.
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks