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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
lennox25
Post Patron
Post Patron

Standard Deviation of total sales

Hi again :), 

 

I have been trying to get a standard deviation calculation in Power Bi. I dont seem to be getting it right.

 

This is my excel table. Any help really appreciated.

 

lennox25_0-1725288448302.png

 

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @lennox25 

 

It would be something like this:

Std dev =
Var InitialDate =
If(
    month(SELECTEDVALUE('month avg'[Month Year])) >= 4
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year])),04,01)
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year]))-1,04,01)
)
Var FinalDate =
If(
    month(SELECTEDVALUE('month avg'[Month Year])) >= 4
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year]))+1,03,31)
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year])),03,31))

Return
 CALCULATE(STDEV.P('month avg'[Total Sales Per Month])
 ,ALLSELECTED('month avg'[Month Year])
 ,DATESBETWEEN(
    'month avg'[Month Year]
    ,InitialDate
    ,FinalDate
 ))
 
However I am unsure which StdDev you would need.
 
Then both have X variations for calculating the StdDev using an expression.
 
Apologises Greg_Deckler I did not see you had replied!

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Thanks for the reply from Greg_Deckler, SamWiseOwl and GuillaumePower.

 

Hi @lennox25 ,

 

Based on the ideas SamWiseOwl provided, can you just create a calculated column to get the correct answer, here is my test result:

Column = STDEV.P('Table (2)'[Total Sales])

vlinhuizhmsft_0-1725434255044.png

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

GuillaumePower
Resolver I
Resolver I

StdDev =
// You have to use sumx on all the value from your table (with power,average and minus)
var LaSommeDesEcarts = sumx('Table',power((AVERAGE('Table'[valeurs])-'Table'[valeurs]),2))
// You divide on the number of elements
var NbElements=count('Table'[valeurs])
// You choose the sqrt
var Resultats = sqrt(divide(LaSommeDesEcarts,NbElements))
return Resultats

 

 

GuillaumePower_0-1725290808207.png

 

Ohhh, I don't have understood that you need to use the date in this calcul....

SamWiseOwl
Super User
Super User

Hi @lennox25 

 

It would be something like this:

Std dev =
Var InitialDate =
If(
    month(SELECTEDVALUE('month avg'[Month Year])) >= 4
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year])),04,01)
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year]))-1,04,01)
)
Var FinalDate =
If(
    month(SELECTEDVALUE('month avg'[Month Year])) >= 4
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year]))+1,03,31)
    ,Date(YEAR(SELECTEDVALUE('month avg'[Month Year])),03,31))

Return
 CALCULATE(STDEV.P('month avg'[Total Sales Per Month])
 ,ALLSELECTED('month avg'[Month Year])
 ,DATESBETWEEN(
    'month avg'[Month Year]
    ,InitialDate
    ,FinalDate
 ))
 
However I am unsure which StdDev you would need.
 
Then both have X variations for calculating the StdDev using an expression.
 
Apologises Greg_Deckler I did not see you had replied!

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Hi @SamWiseOwl  - any idea why its saying this? Im using my date table.

 

lennox25_0-1725291470180.png

 

Hi @lennox25 have you set your Month Year to be a Date data type?


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Hi @SamWiseOwl , yes but on doing that its now format for March 23 as 01/03/2023 - is this right?

The Std Deviation results are this as below, im not sure where Im going wrong? 

lennox25_1-1725367647288.png

 

lennox25_0-1725367606273.png

 

Greg_Deckler
Community Champion
Community Champion

@lennox25 Can you post data as text?



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...

MonthYear  Total Sales      Std Dev
Apr 23         67076             8,516
May 23        75713             8,516
Jun 23         63500             8,516
Jul 23          62006             8,516
Aug 23        73358             8,516
Sep 23        61440             8,516
Oct 23        76631             8,516
Nov 23       88816             8,516
Dec 23       77698             8,516
Jan 24        86106             8,516
Feb 24       78599             8,516
Mar 24      74128             8,516

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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