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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculate Standard deviation from a measure

Hello, 

 

I appreciate that there are a few articles on here however,frustratingly I am yet to find one that solves my query.

 

Essentially I need to calculate the Standard deviation from a DAX measure as I am looking to calculate the count of incidents. To calculate the count of incidents I use the following Measure:

 

Count Of incidents = COUNTA('ssc_db_001 ga_incident_report'[id])

 

Now I would like to count the standard devation by store & Incident type.

I have used the following Formulas, to no effect.

 

(Test)Standard Deviation count of incidents = STDEVX.P('ssc_db_001 ga_incident_report',[Count Of incidents])
stdevm = CALCULATE(STDEVX.P(VALUES('ssc_db_001 ga_incident_report'[Incident type]),CALCULATE(COUNT('ssc_db_001 ga_incident_report'[id]))))
SD Test 2 var = 
   var countofincicent=[Count Of incidents]

   Return CALCULATE(STDEVX.P('ssc_db_001 ga_incident_report',[Count Of incidents]))

 

finno14_1-1629806048345.png

finno14_2-1629806489742.png

 

I recieve an output from Stdevm in regards to a store output however it is wrong- When I collapse the periods, the first store has a SD of 119, from P01-P06 however it should be 21.

 

STdevm does not put an output for incident type however it does total at the bottom- This may be due to the filters but im unsure?

 

I would need the solution to be dynamic/react to filter context. If anyone could help Id be forever in your debt!

 

Kind regards,


Alex

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Since you are using the iterator function STDEVX.P, you can refer to this post to understand the context in the iterator function.


If you want to calculate the standard deviation for different periods and different stores, you can use the following formula.

 

Measure = 
IF(
    ISFILTERED('ssc_db_001 ga_incident_report'[Period]), 
    STDEVX.P( 
        VALUES('ssc_db_001 ga_incident_report'[Incident type]), 
        CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) ) 
    ),
    IF(
        ISFILTERED('ssc_db_001 ga_incident_report'[Store name]),
        STDEVX.P( 
            VALUES('ssc_db_001 ga_incident_report'[Period]), 
            CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) ) 
        ),
        STDEVX.P( 
            VALUES('ssc_db_001 ga_incident_report'[Store name]), 
            CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) )
        )
    )
)

vkkfmsft_0-1630051885926.png

vkkfmsft_1-1630051899037.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg, 

 

Thank you for your response. I have addapted the measure however I am still getting the same results- Obviously I am going wrong somehwere but I am unsure where.

finno14_0-1629904720130.png

 

Any further guidance would be great!

 

Thank you for your time & help!

Hi @Anonymous ,

 

Since you are using the iterator function STDEVX.P, you can refer to this post to understand the context in the iterator function.


If you want to calculate the standard deviation for different periods and different stores, you can use the following formula.

 

Measure = 
IF(
    ISFILTERED('ssc_db_001 ga_incident_report'[Period]), 
    STDEVX.P( 
        VALUES('ssc_db_001 ga_incident_report'[Incident type]), 
        CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) ) 
    ),
    IF(
        ISFILTERED('ssc_db_001 ga_incident_report'[Store name]),
        STDEVX.P( 
            VALUES('ssc_db_001 ga_incident_report'[Period]), 
            CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) ) 
        ),
        STDEVX.P( 
            VALUES('ssc_db_001 ga_incident_report'[Store name]), 
            CALCULATE( COUNTA('ssc_db_001 ga_incident_report'[id]) )
        )
    )
)

vkkfmsft_0-1630051885926.png

vkkfmsft_1-1630051899037.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors