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
CloudMonkey
Post Prodigy
Post Prodigy

Standard deviations of a calculated measure

Hi,

 

Please can you tell me how to calculate the standard deviation of a calculated measure? I can only find examples that use calculated columns, not calculated measures. Is it even possible?

 

I need to find the standard deviation in transaction values ($). I have a calculated measure called "TotalRevenue" and a table field called "TransactionID". There are several table rows per TransactionID so I think I need to group by TransactionID when doing the standard deviation calculation (I need to find the standard deviation between TransactionID's not between table rows)

 

Thank you for any pointers you can give,

 

CM

12 REPLIES 12
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @CloudMonkey,

 

You can use STDEVX.P() function which supports to calculate based on measure.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Use a VAR statement to create a temporary table using something like SUMMARIZE, etc. Include your measure in the table initially or use an ADDCOLUMNS statement to add your measure. Then you can use that temporary table to calculate your standard deviation.

 

I actually use this technique in my MC Aggregations Quick Measure:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thanks again for trying but I'm afraid this is also too complicated. I'll pull the data into excel and do the calculations there.

 

Thanks,

 

CM

If you could supply sample data I bet I could knock this out in like 5 minutes. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, thanks but it's needs to be understandable to analysts without advanced power bi coding otherwise it won't be stable in our company.

Hopefully 2 lines of code is understandable.

 

Measure StdDev = 
VAR __table = SUMMARIZE(Table1,[Column1],"__Measure",[Measure])
RETURN STDEVX.P(__table,[__Measure]) 

Attached sample PBIX as well.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you for your solution AND your sample PBIX. Great answer and not too complicated (once I figured out the DAX syntax LOL)!

Hey Greg,

Our system has a rule ID and a Firing ID. The rule ID stays the same, but with each "firing" there is a new firing ID. I would like to see if there are any rapid increases or decreases in the count of rule IDs per month. I will be looking at 2 years of data and I was thinking about doing a formula that compares the count to see if it is 2 standard deviations away from the average. Is this the best method to find obscurities? Does this make sense? Do you have any suggestions?

 

Thank you,

Seth

Anonymous
Not applicable

Were you able to do as you described?

What if the measure is a result of info from 2 tables?

How would the code look then?

Anonymous
Not applicable

@Greg_Deckler  This is awesome thank-you so much!

Anonymous
Not applicable

Love it!!!

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.