Forum Discussion
jaml
6 years agoRegular Visitor
Comparing stock periods
Hi guys, I would like your help with a private project of mine. I hope you have some ideas. This is probably very easy for some of you. Once a week I copy my entire portfolio and insert it in...
- 6 years ago
Hi, jaml
Based on your description, I created data to reproduce your scenario.
You may create measures as follows.
From period = CALCULATE( MIN('Table'[Timestamp]), FILTER( ALLSELECTED('Table'), 'Table'[Stock Name] = MAX('Table'[Stock Name]) ) ) To period = CALCULATE( MAX('Table'[Timestamp]), FILTER( ALLSELECTED('Table'), 'Table'[Stock Name] = MAX('Table'[Stock Name]) ) ) Amount = var x = [To period] var y = [From period] return CALCULATE( SUM('Table'[Amount of stocks]), 'Table'[Timestamp] = x )- CALCULATE( SUM('Table'[Amount of stocks]), 'Table'[Timestamp] = y )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-alq-msft
6 years agoCommunity Support
Hi, jaml
Based on your description, I created data to reproduce your scenario.
You may create measures as follows.
From period =
CALCULATE(
MIN('Table'[Timestamp]),
FILTER(
ALLSELECTED('Table'),
'Table'[Stock Name] = MAX('Table'[Stock Name])
)
)
To period =
CALCULATE(
MAX('Table'[Timestamp]),
FILTER(
ALLSELECTED('Table'),
'Table'[Stock Name] = MAX('Table'[Stock Name])
)
)
Amount =
var x = [To period]
var y = [From period]
return
CALCULATE(
SUM('Table'[Amount of stocks]),
'Table'[Timestamp] = x
)-
CALCULATE(
SUM('Table'[Amount of stocks]),
'Table'[Timestamp] = y
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jaml
6 years agoRegular Visitor
v-alq-msft This is great, thank you so much for your help! Greatly appreciated