Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:41:31+00:00 2026-05-26T13:41:31+00:00

I have a serious problem with calculating Standard Deviation within subgroup in SSRS/SQl (whichever

  • 0

I have a serious problem with calculating Standard Deviation within subgroup in SSRS/SQl (whichever is more convenient). The real reason behind this is I need to calculate Sigma value (according to Six Sigma principles) or alternatively Cpk value (process capability), but my efforts stop at the standard deviation.

I’m not strong with statistics but it seems that StDev and StDevP functions in SSRS (and SQL) are not calculated ‘within subgroup’, and I cannot find a function that could do that. Below is an excel screen shot showing the calculation steps which I would like to achieve in SQL/SSRS
Edit: Cannot post images yet, please find below

enter image description here

The tricky part is calculating the sum of absolute differences between each pair of values. The order in which the values are given is significant. I forgot to mention that number 27 in denominator of Rbar (Row 7) is the sample size minus 1 (27). Below is also a table in SQL:

DECLARE @Measurements TABLE(Val FLOAT)
INSERT INTO @Measurements (Val)(
    SELECT 485
    UNION ALL SELECT 490.6
    UNION ALL SELECT 490.6
    UNION ALL SELECT 485
    UNION ALL SELECT 485
    UNION ALL SELECT 489
    UNION ALL SELECT 485
    UNION ALL SELECT 477
    UNION ALL SELECT 477
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 485
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 485
    UNION ALL SELECT 485
    UNION ALL SELECT 477
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 484.6
    UNION ALL SELECT 482
    UNION ALL SELECT 482
    UNION ALL SELECT 482
)
SELECT STDEV(Val) FROM @Measurements 

I’m guessing that what I need could be achieved by using either RollingValue or some stored procedure in SSRS. Of course if there is a smarter way to calculate Sigma or Cpk I’ll be very happy to hear about it.

I hope the question is well formulated, if not please comment. This is very important for me so I will be grateful for any assistance 🙂 Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:41:32+00:00Added an answer on May 26, 2026 at 1:41 pm

    I think this should do the trick? Not sure how the denominator of 27 was calculated or the d2 value, so have hard coded them in for now…

    In terms of using this query it is important to preserve the row order, so I have whacked the values into a temp table using an identity column – if your values are coming from a table and there is a fixed criteria for ordering, use row_number() OVER (order by criteria_column) instead

    IF OBJECT_ID('tempdb..#values') IS NOT NULL DROP TABLE #values
    CREATE TABLE #values (row INT IDENTITY (1,1),val FLOAT)
    INSERT INTO #values
        SELECT 485 as val
        UNION ALL SELECT 490.6 
        UNION ALL SELECT 490.6 
        UNION ALL SELECT 485 
        UNION ALL SELECT 485 
        UNION ALL SELECT 489 
        UNION ALL SELECT 485 
        UNION ALL SELECT 477 
        UNION ALL SELECT 477 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 485 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 485 
        UNION ALL SELECT 485 
        UNION ALL SELECT 477 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 484.6 
        UNION ALL SELECT 482 
        UNION ALL SELECT 482 
        UNION ALL SELECT 482 
    
    
    
    ;with stdevs AS
    (
    SELECT 
    v1.val
    ,ABS(v1.val - v2.val) as abs_diff
    ,v2.val as value2
    from #values v1
    LEFT OUTER JOIN #values v2
    ON v2.row = v1.row + 1
    )
    SELECT
    avg(val) as average_value
    ,sum(abs_diff) as abs_sum
    ,sum(abs_diff) / 27 as Rbar
    ,1.13 as d2
    ,(sum(abs_diff) / 27) / 1.13 as std_dev
    FROM stdevs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this serious problem. I have an enumeration within 2 namespaces like this:
I have a real serious problem with maple, I can't get it to display
I have a serious problem with getting data from a sql query in php
I have a serious problem. One of our servers crashed. Now I reinstalled the
Ok guys, I have a serious problem with this. I have a static class
I have a serious performance problem. I have a database with (related to this
I have a serious problem with hibernate. I followed various books und online tutorials,
I have a serious problem in my app. I wrote a facebook like instant
i have a serious problem here. i'm trying to use a modal window in
I have serious problem I can not pass my data to controller when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.