Forum Discussion
mike87
8 years agoFrequent Visitor
Calculating changes on daily data
Hi, I am trying to create a measure that calculates the daily change for a stock price. I have tried to use LASTDATE function, but for some wierd reason, it turns out December 31th 2017 instead ...
- 8 years ago
Hi mike87
Try this MEASURE.
File attached here as wellPriceChange = VAR LastPirce = CALCULATE ( VALUES ( Table1[Stock Price] ), FILTER ( Table1, Table1[Date] = MAX ( Table1[Date] ) ) ) VAR SecondLastDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < MAX ( Table1[Date] ) ) ) RETURN LastPirce - CALCULATE ( VALUES ( Table1[Stock Price] ), Table1[Date] = SecondLastDate )
v-jiascu-msft
8 years agoMicrosoft Employee
Hi mike87,
Yes, I usually use it in such scenario. That could depend on your data model and the visual you create. Can you share your pbix file?
Best Regards!
Dale
mike87
8 years agoFrequent Visitor
I have uploaded a couple of images from the data set and the dashboard.
It is simple stock data with closing price and dates.
Norwegian numbers with comma as decimals separators
- Zubair_Muhammad8 years agoCommunity Champion
Hi mike87
Try this MEASURE.
File attached here as wellPriceChange = VAR LastPirce = CALCULATE ( VALUES ( Table1[Stock Price] ), FILTER ( Table1, Table1[Date] = MAX ( Table1[Date] ) ) ) VAR SecondLastDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < MAX ( Table1[Date] ) ) ) RETURN LastPirce - CALCULATE ( VALUES ( Table1[Stock Price] ), Table1[Date] = SecondLastDate )- mike878 years agoFrequent Visitor
Thank you Zubair_Muhammad.
That worked perfectly