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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ShrewdOperator
Regular Visitor

How to aggregate grouped data with DAX measure. (Equivalent to Over Clause?)

Hey there,

 

I was hoping someone could help with a measure I've been struggling with for the last few hours.

 

On PowerBI I want to use a measure (or use a calculated column if more suitable) to compare the total revenue values of each employee, and calculate the standard deviation on just the grouped figures of total revenue for each employee, which excel calulates it as 800.53.

 

Does anyone know how I might be able to get a measure that disregards the individual sales revenue figures and calculates the standard deviation just based on the total sum revenue figures of each employee?

 

The table below was created with Excel formulas but this is essentially what I want the measure to produce on PowerBI. 

 

Employee IDSum of Total SalesAverage of TotalsStandard Deviation of Totals
13100.001787.92800.53
23102.301787.92800.53
32363.041787.92800.53
42000.001787.92800.53
51749.871787.92800.53
61641.431787.92800.53
71387.771787.92800.53
81299.251787.92800.53
91283.611787.92800.53
101203.111787.92800.53
11536.751787.92800.53

 

I had no trouble creating the third column above for the Average of Totals; below was the measure I used to create that.  But to work out Standard Deviation of the totals using STDEV functionality has been difficult. 

 

Average Of Total Measure = 

CALCULATE(SUMx(SalesTable,
CALCULATE(SUM(SalesTable[Total]),ALL(SalesTable[Employee_ID]))
/DISTINCTCOUNT(SalesTable[Employee_ID])),
ALL(SalesTable[Employee_ID]))

 

As you've probably already guessed, I'm fairly new to some aspects of PowerBI and maybe I'm missing something very obvious, though I appreciate any help anyone can provide.

 

Thank you,

Shrew

1 ACCEPTED SOLUTION

Hey Guys,

 

I just wanted to update on my post. After doing a bit more digging I eventually got my solution, though I'm unsure if it's the best approach. 

 

Nevertheless I ended up creating a seperate table with just the employee details and created a sum measure on the main table of sum total per employee:

 

CaptureSunday1.JPG

 

 

I then created a new column in the new table and referenced that measure:

 

CaptureSunday2.JPG

 

 

And I was then able to do a simple dax formula to find standard deviation of the summed values like below to get the figures I needed:

 

CaptureSunday3.JPG

 

Again like I say, I'm not sure if this is the most elegant way of performing this but there wasn't that much literature out there that discusses what I was looking for; so if anyone has any advice about a simpler, more optimal way of perform this, please let me know. 

 

Thanks, 

Shrew  Smiley Happy

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

You just need to use the STDEV.S function instead of the STDEV.P function:

 

Measure 3 = STDEV.S(Table7[Sum of Total Sales])

No need to calculate the average the function will do that for you.

 

Would help though to know your source data that you are working with. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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

Hey Greg,

 

Thank you for responding to my post.

 

So, I've tried using the StDEV.S/P in my measures but by themselves they aren't producing the single standard deviation value I'm looking for. 

 

With the reccomended measure you've given, it produces a distinct standard deviation value for each employee, which is based on their own respective sales totals. Like so below: 

 

Employee IDStdDev of Employee Total
1340.18
2304.93
3297.93
4622.91
5185.72
6266.95
7217.93
8672.20
9661.40
10336.25
11760.67
Grand Total441.31

 

The measure I'm looking to create, the stages would go something like this. 

 

First, here is a sample of the source table which list all sales and it would be this table that the measure is based on.

 

OrderDateRegionEmployee IDItemUnitsUnit CostTotal
06/01/2016East2Pencil951.99189.05
23/01/2016Central3Binder5019.99999.5
09/02/2016Central4Pencil364.99179.64
26/02/2016Central5Pen2719.99539.73
15/03/2016West6Pencil562.99167.44
01/04/2016East2Binder604.99299.4
18/04/2016Central7Pencil751.99149.25
05/05/2016Central4Pencil904.99449.1
22/05/2016West8Pencil321.9963.68
08/06/2016East2Binder608.99539.4
25/06/2016Central9Pencil904.99449.1

 

 

 

 

 

From the source table I want to work out the total revenue for each employee, like below:

 

 

Employee IDSum of Total
22363.04
33109.44
44406.71
51749.87
61283.61
71299.25
81203.11
91387.77
10536.75
113102.30
121641.43
Grand Total22083.29

 

I then want to take those summed figures of each employee and calculate the standard deviation on just the the summed fugures. Which would look something like this below: 

 

Employee IDSum of TotalStandard Deviation
22363.041075.16
33109.441075.16
44406.711075.16
51749.871075.16
61283.611075.16
71299.251075.16
81203.111075.16
91387.771075.16
10536.751075.16
113102.301075.16
121641.431075.16

 

The average that you saw in my first post is to be used for other purposes seperate from the standard deviation.

 

Please let me know if there's something I've not covered and thank you for your help. 

 

Shrew,

Smiley Happy

Hey Guys,

 

I just wanted to update on my post. After doing a bit more digging I eventually got my solution, though I'm unsure if it's the best approach. 

 

Nevertheless I ended up creating a seperate table with just the employee details and created a sum measure on the main table of sum total per employee:

 

CaptureSunday1.JPG

 

 

I then created a new column in the new table and referenced that measure:

 

CaptureSunday2.JPG

 

 

And I was then able to do a simple dax formula to find standard deviation of the summed values like below to get the figures I needed:

 

CaptureSunday3.JPG

 

Again like I say, I'm not sure if this is the most elegant way of performing this but there wasn't that much literature out there that discusses what I was looking for; so if anyone has any advice about a simpler, more optimal way of perform this, please let me know. 

 

Thanks, 

Shrew  Smiley Happy

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.