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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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