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
MindIsBlank
Frequent Visitor

DAX Version of Excel's DSTDEV

New to Power BI but have some experience with Tableau.

 

Looking to add a measure that calculates the standard deviation for unique categorical values in a column. For example, Column A has a category. Column B has the values on which I need to calculate the standard deviation. I need to calculate the st dev of Column B for all unique categories of Column A. Example data below:

 

Column AColumn B
Name1204.0730158
Name27176.691379
Name3129.2877416
Name1205.8627572
Name27203.935509
Name3130.522898
Name1207.2325321
Name27231.588786
Name3130.8039379

 

Name1 st dev would use 204.0730158, 205.8627572, and 207.2325321. Name2 and Name3 st deve would follow in similar manner. Hoping to setup a measure that would do all that for me so I can use it in line charts and scatter plots.

 

Any ideas? Thanks in advance.

1 ACCEPTED SOLUTION

I figured it out. Had to use nested filtering described in this article from 2012.

 

Measure code looks like this:

 

calculate(
     STDEV.P(Column B)
     ,FILTER(
          ALL('Table')
          ,COUNTROWS(
               FILTER(
                    'Table'
                    ,EARLIER(Column A) = Column A
               )
          )
     )
)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Measure =

Calculate (

        STDEV.P('TableName'[ColumnB]),

        ColumnA = "Name1")

Yeah, I thought of that but I need it to dynamically load what goes into the CALCULATE() filter based on the row Power BI is evaluating. So it would be something like:

 

Calculate (

        STDEV.P('TableName'[ColumnB]),

        ColumnA = {Value from Column A in row being evaluated})

 

I just can't figure out how to tell it to do it that way. Another way I've gotten this to work in Excel is using the following formula as an array formula.

 

=STDEV.P(IF($A$2:$A$9000=A2,$B$2:$B$9000))

I figured it out. Had to use nested filtering described in this article from 2012.

 

Measure code looks like this:

 

calculate(
     STDEV.P(Column B)
     ,FILTER(
          ALL('Table')
          ,COUNTROWS(
               FILTER(
                    'Table'
                    ,EARLIER(Column A) = Column A
               )
          )
     )
)

Tahreem24
Super User
Super User

Create a measure like below:
SD=STDEV.P(Table[SalesAmount])

Don't forget to give thumbs up 👍and accept this as a solution if this helps you.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.