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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NetromEner
Frequent Visitor

Standard Deviation for QTY sold by yearly basis

Hi,

 

I am trying to migrate from Excel to power BI and need some help with the DAX. I am trying to find the standard deviation based on yearly sales per product code. The goal is to accomplish somthing similar to below Excel version.

 

result.jpg

 

 

 

 

My data is structured like the below table and I want to find standard deviation for total QTY sold per year for each product, in this case  product no 33270
data table.jpg

 

 

 

 

 

 

 

 

 

 

 

I got the yearly average and QTY sold per year sorted out in my report as shown below.

 

Report view.jpg

 

 

 

 

 

I really hope someone can guide me on my way.

 

Best Regards

Morten

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @NetromEner ,

Here are the steps you can follow:

1. Create calculated column.

STDEVXS =
STDEVX.S(FILTER(ALL('Table'),'Table'[Product Code]=EARLIER('Table'[Product Code])&&'Table'[Year]=EARLIER('Table'[Year])),[QTY])
STDEVXP =
STDEVX.P(FILTER(ALL('Table'),'Table'[Product Code]=EARLIER('Table'[Product Code])&&'Table'[Year]=EARLIER('Table'[Year])),[QTY])

2. Result:

STDEVX.S formula:

√[∑(x - x̃)2/(n-1)]

STDEVX.S function (DAX) - DAX | Microsoft Learn

STDEVX.P formula:

√[∑(x - x̃)2/n]

STDEVX.P function (DAX) - DAX | Microsoft Learn

vyangliumsft_0-1668396919907.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @NetromEner ,

Here are the steps you can follow:

1. Create calculated column.

STDEVXS =
STDEVX.S(FILTER(ALL('Table'),'Table'[Product Code]=EARLIER('Table'[Product Code])&&'Table'[Year]=EARLIER('Table'[Year])),[QTY])
STDEVXP =
STDEVX.P(FILTER(ALL('Table'),'Table'[Product Code]=EARLIER('Table'[Product Code])&&'Table'[Year]=EARLIER('Table'[Year])),[QTY])

2. Result:

STDEVX.S formula:

√[∑(x - x̃)2/(n-1)]

STDEVX.S function (DAX) - DAX | Microsoft Learn

STDEVX.P formula:

√[∑(x - x̃)2/n]

STDEVX.P function (DAX) - DAX | Microsoft Learn

vyangliumsft_0-1668396919907.png

 

Best Regards,

Liu Yang

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

zerotyper
Frequent Visitor

@NetromEner  The Dax also has the specific function to calculate the Standard Deviation

zerotyper_0-1668182098335.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors