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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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