Forum Discussion
Anonymous
3 years agoNot applicable
Calculating variable stock returns
Hi, I would like to make a visual of top 10 stocks differences, but with variable return horizon(ie, price_today - price 2 days before, or price_today - price n days before) where n is given by a me...
- 3 years ago
Hi, Anonymous
You can try the following methods.
Measure:price n day = VAR _N = SELECTEDVALUE ( 'Table'[date] ) - 1 RETURN CALCULATE (SUM ( 'Table'[close] ), FILTER (ALL ( 'Table' ), [symbol] = SELECTEDVALUE ( 'Table'[symbol] ) && [date] = _N ) )Difference = IF([price n day]=BLANK(),0,SUM('Table'[close])-[price n day])Change 1 to 2 to get the difference from the previous 2 days.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
v-zhangti
3 years agoCommunity Support
Hi, Anonymous
You can try the following methods.
Measure:
price n day =
VAR _N = SELECTEDVALUE ( 'Table'[date] ) - 1
RETURN
CALCULATE (SUM ( 'Table'[close] ),
FILTER (ALL ( 'Table' ),
[symbol] = SELECTEDVALUE ( 'Table'[symbol] )
&& [date] = _N ) )Difference = IF([price n day]=BLANK(),0,SUM('Table'[close])-[price n day])
Change 1 to 2 to get the difference from the previous 2 days.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly