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
dont_forget
New Member

Standard Deviation of Values from Several Tables

I'm something of a PowerBI Desktop and DAX newbie, so please excuse me if this question is really simple.

 

I have five guys working for me, and I would like to create a visual that shows the number of calls each indivdiual handle per month on average, the average calls handled per month per person across the entire group, and finally the average calls plus one standard deviation and minus one standard deviation. I am able to do this in Excel, but I can't make it happen in PowerBI. The way the math works, I can figure out the average pretty easy. I'll just create one average measure for each individual, and then find the average of the five individual average measures. However in order to determine the standard deviation I need to figure out a way to feed all the values within a specifc column across five tables into one of the STDEV variants. I would very much like to do this in a way allows me to filter, and the average of averages updates as well as the STDEV.

 

 

My data is seperated into a table for each guy, and looks something like this:

Year    Month   Number of Calls

2016    Jan        455

2016    Feb       500

 

 

Capture.JPG

 

 

Thanks!

2 ACCEPTED SOLUTIONS

Hi @dont_forget,

 

I modify the sample, perhaps you can take a look at below sample if it suitable for your requirement.

 

Merged table:

Table = UNION( ADDCOLUMNS(Sheet1,"Staff","Staff 1"), ADDCOLUMNS(Sheet2,"Staff","Staff 2"), ADDCOLUMNS(Sheet3,"Staff","Staff 3"))

 

Capture.PNG

 

Add calculate column to stored the date(use to sort).

 

Date = 
var temp=SWITCH([Month],"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)
return
CONCATENATE([Year],if(LEN(temp)>1,temp,"0"&temp))

 

 

Measures.

Calculate the average:

 

Average = 
var currMonth=LASTNONBLANK('Table'[Month],[Month])
var currYear=LASTNONBLANK('Table'[Year],[Year])
return
 AVERAGEX(FILTER(ALL('Table' ),[Month]=currMonth&&[Year]=currYear),[Handled Calls])

 

 

Calculate the STDEV:

 

STDEV = 
var currMonth=LASTNONBLANK('Table'[Month],[Month])
var currYear=LASTNONBLANK('Table'[Year],[Year])
return
STDEVX.P(FILTER(ALL('Table' ),[Month]=currMonth&&[Year]=currYear),[Handled Calls])

 

Create a visual to show the result:

 

Capture2.PNG

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Personally I would unpivot your data using Power Query before loading.

 

Select columns Handled, Internal, Transfere, OutExtn and unpivot them.  This will create 2 new columns "Call type" and Value.  You can then delete Total Calls as you can always recalc this by summing the new column.  Once you have all the calls in a single column, everything else becomes easier.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

6 REPLIES 6

Can you please show a sample of your data tables. The answer depends on the table and column structure



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thanks for the quick response Matt. Here is one of the tables (the other four are identical):

 

YearMonthLoggedOnTimeAHTHandled CallsInternal CallsTransfered CallsOutExtnCallsTotal CallsStaffed TimeCPH
2015January359:05:340:04:36595201575705359.091.96
2015February342:35:060:04:36582374266727342.592.12
2015March329:08:060:04:32595183178722329.142.19
2015April327:49:020:04:32617223294765327.822.33
2015May251:25:180:04:24523132752615251.422.45
2015June271:25:280:04:53498151268593271.422.18
2015July377:50:330:04:24797353185948377.842.51
2015August299:51:060:04:25488231451576299.851.92
2015September316:19:160:04:2457892051658316.322.08
2015October359:49:260:04:11690173451792359.822.20
2015November297:32:240:04:29490272658601297.542.02
2015December385:21:320:04:19505343459632385.361.64
2016January614:27:460:04:41548383156673614.461.10
2016February325:25:160:04:45556433058687325.422.11
2016March389:46:440:04:37644392977789389.782.02
2016April316:25:140:04:44492353748612316.421.93
2016May370:01:100:04:2161142347694370.021.88
2016June357:19:000:04:10611422243718357.322.01
2016July260:30:300:04:33517273550629260.512.41
2016August222:21:000:04:14421273440522222.352.35
2016September348:54:140:04:22616495647768348.902.20
2016October339:24:080:04:55558346228682339.402.01
2016November389:57:460:04:50479384737601389.961.54
2016December313:18:000:04:26457425116566313.301.81

Personally I would unpivot your data using Power Query before loading.

 

Select columns Handled, Internal, Transfere, OutExtn and unpivot them.  This will create 2 new columns "Call type" and Value.  You can then delete Total Calls as you can always recalc this by summing the new column.  Once you have all the calls in a single column, everything else becomes easier.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi @dont_forget,

 

Baed on your description, you want to get the each staff's average value per month, right?

 

If this is a case , you can refer to below steps.

 

1. Add staff column and merget the tables.

 

Table = Union(ADDCOLUMNS(Sheet1,"Staff","Staff 1"),ADDCOLUMNS(Sheet2,"Staff","Staff 2"),
ADDCOLUMNS(Sheet3,"Staff","Staff 3"),ADDCOLUMNS(Sheet4,"Staff","Staff 4"),ADDCOLUMNS(Sheet5,"Staff","Staff 5"))

 

 

2. Add measure to calculate each staff's monthly average.

 

Average = 
var currStaff=LASTNONBLANK('Table'[Staff],[Staff])
var currMonth=LASTNONBLANK('Table'[Month],[Month])
return
 AVERAGEX(FILTER(ALL('Table' ),[Staff]=currStaff&&[Month]=currMonth),[Staffed Time])

 

Avg - = [Average] - 100 

 

 

Avg + = [Average] + 100 

 

3. Create the visual to show the result.

Capture.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi Xiaoxin,

 

I'm actually looking to get the standard deviation of all 5 individuals calls per month. The average isn't a problem, as I can take an average of the average, and the math will work out such that it is accurate. I can't take the average of the individual's standard deviation. That would not be representative of the overal standard deviation. The standard deviation allows me to create a stastically informed upper control limit and lower control limt, rather than using a number like 100.

 

In excel I was able to do it by =STDEV.P(Staff1[Handled Calls],Staff2[Handled Calls],Staff3[Handled Calls],Staff4[Handled Calls]Staff5[Handled Calls]). I can't figure out a similar way to do the same syntax in DAX.

 

Very intersting way to pull up the average though. I learned something.

 

Thanks!

Nate

Hi @dont_forget,

 

I modify the sample, perhaps you can take a look at below sample if it suitable for your requirement.

 

Merged table:

Table = UNION( ADDCOLUMNS(Sheet1,"Staff","Staff 1"), ADDCOLUMNS(Sheet2,"Staff","Staff 2"), ADDCOLUMNS(Sheet3,"Staff","Staff 3"))

 

Capture.PNG

 

Add calculate column to stored the date(use to sort).

 

Date = 
var temp=SWITCH([Month],"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)
return
CONCATENATE([Year],if(LEN(temp)>1,temp,"0"&temp))

 

 

Measures.

Calculate the average:

 

Average = 
var currMonth=LASTNONBLANK('Table'[Month],[Month])
var currYear=LASTNONBLANK('Table'[Year],[Year])
return
 AVERAGEX(FILTER(ALL('Table' ),[Month]=currMonth&&[Year]=currYear),[Handled Calls])

 

 

Calculate the STDEV:

 

STDEV = 
var currMonth=LASTNONBLANK('Table'[Month],[Month])
var currYear=LASTNONBLANK('Table'[Year],[Year])
return
STDEVX.P(FILTER(ALL('Table' ),[Month]=currMonth&&[Year]=currYear),[Handled Calls])

 

Create a visual to show the result:

 

Capture2.PNG

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.