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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Calculating Standard Dev from an aggregate or measure

Hi Guys

 

I have spent over past 2 days trying to figure out a solution to this problem, i have been asked to create a SPC by a client, in which the main table is in this a raw format with multiple rows i.e customer name, day, number of sales etc

 

C TABLE

 

Customer name, day, number of sales

A                       1               10

B                      1               10

C                      1                20

A                      2                10

B                      2                 40

 

So i have managed to create an aggregate table using mixture of different measures which looks like this with day as filter

 

Customer name        Number of sales            Mean             My ideal answer

A                              20                                  30                   13.33

B                               50                                  30                   13.33

C                               20                                 30                    13.33

                                  90                                30

 

Mean is calculated using measure

 

M Measure

 

Total number of sales = SUM(C[Number of Sales])

DISTINCT COUNT of CUS = DISTINCTCOUNT(C[Customer name])

 

Mean = CALCULATE (DIVIDE(M[Total Number of Sales], M[DISTINCT COUNT of CUS], ALLEXCEPT(C, C[Day]))

 

I have tried to apply the similar logic to work out Standard Derivation using STDV.P against C[Number of sales], but realised that the STDV.P is calculating the derviation of the C table and not the aggregate table. 

 

So next i have tried using the same approach with SQRT((Total Sales - Mean)^2) - but realised that the result showing as

 

A       SQRT( (20-30)^2)

B        SQRT( (50-30)^2)

C        SQRT( (20-30)^2)

          SQRT( (90-30)^2) <<<< which is wrong it should be average of all above

 

My ideal answer for all rows for the aggregate table should be 

 

AVERAGE( SQRT( (20-30)^2) + SQRT( (50-30)^2) +  SQRT( (20-30)^2)) which is STDV.P on my aggregate NOT my table

 

I am getting to stage of giving up and would be grateful if any guru or master can help!!!!!!!!!!!!!!!!!!   Smiley Sad

 

Happy to share the file 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

update**

 

Managed to solve the problem by using

 

3 seperate measure:

 

1. calculate the sum of values (using SUM( No of Sales ) )

2. Using STDEVX.P( C Table, SUMMARISE(Customer Name, CALCULATE ( 1st Measure ))

3. CALCULATE( 2nd Measure, ALLSELECTED(Customer Name)

 

Hopefully this will help others with the similar problem

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

update**

 

Managed to solve the problem by using

 

3 seperate measure:

 

1. calculate the sum of values (using SUM( No of Sales ) )

2. Using STDEVX.P( C Table, SUMMARISE(Customer Name, CALCULATE ( 1st Measure ))

3. CALCULATE( 2nd Measure, ALLSELECTED(Customer Name)

 

Hopefully this will help others with the similar problem

v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

 

You may try below measure:

answer =
VAR a =
    SUMMARIZE (
        ALLEXCEPT ( C, C[day] ),
        C[Customer name],
        "b", SQRT ( ( [Total number of sales] - [Mean] ) ^ 2 )
    )
RETURN
    AVERAGEX ( a, [b] )

1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

thanks for your reply - will have a look and get back to you.

 

Much appreciated !!

Hi @Anonymous 

 

Could you tell me if your problem has been solved? If it is,kindly mark the helpful answer as a solution and welcome to share your own solution. More people will benefit from here. If not, please share more details for us so that we could help further on it.

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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