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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register 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
Employee
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-...

 


@ 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!:
Mastering Power BI 2nd Edition

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


@ 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!:
Mastering Power BI 2nd Edition

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.


@ 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!:
Mastering Power BI 2nd Edition

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.