Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Moharfaoui
Frequent Visitor

Measure using the outcome of a measure

Hi guys, 

 

I'm new to this community. Thank your for the helpo in advance. 

 

So I am trying to calculate the volatitlity of the Sotck Exchange 

 

1) I have a table with the dates and the Stock Close Price.

2) From that point I did a measure so I can have the return for each date. 

 

Return =
VAR currDate =
MAX ( 'Stock Data'[Date] )
VAR prevDate =
CALCULATE (
MAX ( 'Stock Data'[Date] ),
FILTER ( ALLSELECTED ( 'Stock Data' ), [Date] < currDate && [Close]<> BLANK () ),
VALUES ( 'Stock Data'[Quote Symbol] )
)
VAR prevAmount =
CALCULATE (
SUM ( 'Stock Data'[Close] ),
FILTER ( ALLSELECTED ( 'Stock Data' ), [Date] = prevDate ),
VALUES ( 'Stock Data'[Quote Symbol] )
)
RETURN
DIVIDE ( SUM ( 'Stock Data'[Close] ) - prevAmount, prevAmount )

 

This measure code worked fine. 

 

3) Now, I want to have a measure that calculates the standard deviation for each date for the last returns (outcome of the measure Return). The problem is that STDEVX.S() needs a column (I'm trying to avoid a calculated columns). 

 

I hope I explained the proble that I face. If you need more details, just let me know. 

 

Regards. 

 

1 ACCEPTED SOLUTION

@Moharfaoui 

Try

STDEVX.S ( CALCULATETABLE (VALUES ( Date[Date] ), Date[Date] <= MAX (Date[Date])), [Return] )

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

@Moharfaoui 

Try

STDEVX.S ( VALUES ( Date[Date] ), [Return] )

Hi, 

Thank you for your replay. 

It's working but that not what I'm looking for. (This only calculate the standar deviation for the whole serie and doesn't iterate). 

 

I need to calculate de standar deviation up to date for each date. I leave this table as an example.

 

DATEQUOTE SYMBOLCLOSERETURNVolatility
..................
01/09/2019AAPL152.001.00%4,12%
02/09/2019AAPL

158.00

 

3.94%4,1%
03/09/2019AAPL159.000.63%4,09%
     

 

 

Thank you again. I hope I explain it well. 

@Moharfaoui 

Try

STDEVX.S ( CALCULATETABLE (VALUES ( Date[Date] ), Date[Date] <= MAX (Date[Date])), [Return] )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors