Change From Previous

mgirvin

Well-known Member
Joined
Dec 15, 2005
Messages
1,245
Office Version
  1. 365
Platform
  1. Windows
Dear Team,

I have a table of dates and GE Stock Prices. I would like a Calculated Column that calculates the change in stock value day by day. THE DAX I have created is this:

Calculated Column for Change in GE Stock Prom Previous =

IF (
MIN ( GEPrices[Date] ) = GEPrices[Date],
BLANK (),
GEPrices[GE Close]
- LOOKUPVALUE (
GEPrices[GE Close],
GEPrices[Date], MAXX (
FILTER ( ALL ( GEPrices[Date] ), GEPrices[Date] < EARLIER ( GEPrices[Date] ) ),
GEPrices[Date]
)
)
)

The table I have is this:


Date GE Close
3/8/19 9.58
3/11/19 9.9
3/12/19 9.76
3/13/19 10.02
3/14/19 10.3
3/15/19 9.96
3/18/19 10.2
3/19/19 10.19
3/20/19 10.22
3/21/19 10.27
3/22/19 9.98
3/25/19 9.88
3/26/19 10.1
3/27/19 9.96
3/28/19 9.89
3/29/19 9.99
4/1/19 10.1
4/2/19 10.24
4/3/19 10.1
4/4/19 10.03
4/8/19 9.49

Is this an efficient formula? Is there a better way to do this?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Don't know about efficiency, but this seems more intuitive to me

Code:
=IF(MIN( GEPrices[Date] ) = GEPrices[Date],
    BLANK(),
    GEPrices[GE Close] - LOOKUPVALUE ( GEPrices[GE Close],
                                       GEPrices[Date],
                                       GEPrices[Date]-IF(WEEKDAY(GEPrices[Date],1) = 2,
                                                         3,
                                                         1
                                                        )
                                     )
   )
 
Upvote 0
Thank you, theBardd. That is straight forward and clever : ) That does work for the pattern shown in the data set, but stock price dates do not always follow that pattern.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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