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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
taylorirwin21
Regular Visitor

Standard Deviation for a Calculated Measure

Hi,

 

I am trying to calculate the standard deviation of a Measure in Power BI. The measure calculates the LN return of price changes. When I try to use the function for stadnard deviation below, I only get zeros. 

 

LN Return = LN([Price Measure]/[Previous_Price]
LN Return StDev = STDEVX.P(Prices,[LN Return])
 
taylorirwin21_0-1694728075351.png

 

How can I work around this?

@Ashish_Mathur 

 

Much appreciated,

Taylor

11 REPLIES 11
v-tangjie-msft
Community Support
Community Support

Hi @taylorirwin21 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure. 

LN Return StDev = STDEVX.P(TOPN(10,FILTER(ALL('Table'),'Table'[date]<=MAX('Table'[date])),[date],DESC),'Table'[_LN Return])

(3) Then the result is as follows.

vtangjiemsft_0-1695102436415.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Neeko,

 

Thank you for the reply - my report is still showing zeros for standard deviation when I try your solution. Could it be because my 'Previous Price' and 'LN Return' are both measures themselves? If so, is there a way to convert them to calculated columns or some other fix? 

taylorirwin21_0-1695215668922.png

 

Hi @taylorirwin21 ,

 

Has your problem been solved? If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out. Thanks in advance.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi @taylorirwin21 ,

 

As my pbix shows, the 'Table'[_LN Return] in the LN Return StDev measure is also the measure.

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

Ashish_Mathur
Super User
Super User

Share the file when you can from a non work laptop.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

Please find attached my solution file.  My answers do not match with your but my workings are correct.  Surprisingly, for 13/9/2023, the LN function in MS Excel reveals the answer as 0.00162, the same function returns the result as 0.00216 in PowerBI.

Hope this helps.

Ashish_Mathur_0-1695440933886.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @ lot @Ashish_Mathur , this helped a lot in resolving standard deviation issue.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Create the expected result table in an MS Excel file (with the formulas already there) and share the download link of that file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Unable to share a link as it's a work computer, but here is what it should look like! Should be a rolling StDev. Just used the Stdev formula in excel here.

taylorirwin21_0-1694785453662.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.