Calculating standard deviation of the calculated measure

res.marcus

New Member
Joined
Oct 18, 2012
Messages
19
Hi,

I´m trying to calculate the standard deviation of a calculated measure per variable.

I have a table like this:

DateSum of percentage in variable 1Sum of percentage in variable 2Sum of percentage in variable 3
20123083,0309414555,9727287892,24959921
20123173,8448964751,9434139289,37820926
20123282,1207347853,0219394685,39993252
20123384,6875947248,8820623690,67685169
20123482,7289816453,4993219490,95449111
20123583,1678031561,9630392590,53065014
20123683,022243650,0718819687,64743282
20123787,8013821958,3082870887,8565807
20123869,6747889148,1774432789,66835717
20123977,2310620848,5792640594,64372303
20124075,8374342552,948909392,00524078
20124198,6051999261,0706947188,33355519

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>

And I would like to calculate the standard deviation of these values per vaiable. The requested result for variable 1 in this example is 7,067208565.

When I try to do standard deviation calculations I get one unique value for each week - see below.


DateStandard deviation in variable 1Standard deviation in variable 2Standard deviation in variable 3
2012309,3165252347,3521194928,057547247
2012319,2075683118,42978240510,98418204
2012328,7504279617,5138741598,509357209
2012337,4546981476,3400211679,557455606
2012349,1831967677,645692518,434229083
20123510,595978310,60208199,622005673
2012368,3574640595,6136026748,517430214
2012378,2337849736,4768031868,00956014
2012387,0563057716,84206796410,06065965
2012397,388074396,3086751598,938462481
2012407,9404199737,76629740511,25859248
20124110,605194288,0162904047,702836064

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>


But what I really want is one value that I can use to identify large deviations in the calculated measure.


Does anyone know how to get it right?

Best,
Marcus
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Marcus,

how are you calculating those SD's? Is it a formula / measure over the the other measures you have in place?
Could you maybe get rid of the Date column? Is it in the row labels? The by deleting it there you would come up with the total SD per variable I believe?

HTH
 
Upvote 0
Hi,

Thank you for your quick reply.

I´m currently calculating the values with the DAX standard deviation formula for a population. I cannot really get rid of the date column since i need it to display my other measure - also, even if get rid of it I don't get the results I´d expect - it seems to me that the standard deviation calculations are made on the underlying data (?). What I´m really after is a way to do calculations on the values visible in the table.

Best,
Marcus
 
Upvote 0
Hi,

Could the SUMMARIZE function be used in combination with STDEV.P to generate the result I want?

Seems it should work, but I recieve the error message "Calculation error in measure 'Query'[004af71a-5719-4971-b309-0df239be4dcc]: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value." when I try creating the measure: =SUMMARIZE(Query; Query[Account]; Query[Country]; Query[Industry]; Query[QuestionID]; Query[Question]; "grouped dev"; STDEV.P([Percentage]))

What am I doing wrong?

Best,
Marcus
 
Upvote 0
Hi,

I just wanted to tell you that I solved my problem using =STDEVX.P(summarize(query; query[date]; query[segment]; query[account]; query[country]; query [industry]; query[questionid]; query[question]; "sum percent"; Sum(query[percentage])); [sum percent])

That is creating a table of the summarized values that I calculate the standard deviations for.

Many thanks to the DAX studio developers - the add-in really helped me understand what was going on!

Best,
Marcus
 
Upvote 0
I have a similar problem to the question above. i want to calculate the standard deviation of the most recent 12 previous QUARTERLY amounts given monthly data. My approach was to use an inner calculate along with the datesqtd function to first calculate the quarterly subtotals. Then I think I would use an outer calculate to filter to the last 12 values and calculate the standard deviation. My formula doesn't work. I wonder if someone can look it over and tell me what it is doing wrong. It looks like this:

CALCULATE (
STDEVX.P (
values(lnl[yyyymm]),
CALCULATE (
SUM ( lnl[amount] ),
DATESQTD ( lnl[date] )
)
),
DATESINPERIOD (
lnl[date],
ENDOFQUARTER ( lnl[date] ),
-12,
QUARTER
),
LNL[QtrMnth] <= 3
)

If I use the summarize function, is there still a way to respect the filters that get applied externally from the pivot table?
 
Last edited:
Upvote 0
Looking just at this part, it reads kinda weird to me:

STDEVX.P (

values(lnl[yyyymm]),
CALCULATE (
SUM ( lnl[amount] ),
DATESQTD ( lnl[date] )
)

It seems unlikely you mean QTD here, as that will give you a standard deviation over a weird series of running totals. Jan, Jan+Feb, Jan+Feb+Mar, Apr, Apr+May, ...

That will be a lot of deviation :)

You need to somehow pass a table of QUARTERLY values, so... probably... ?

CALCULATE(STDDEVX.P(VALUES(Calendar[QuarterNum]), [Total Amount]))

 
Upvote 0
I don't really follow what the first parameter of the standard deviation calculation is supposed to do. I tried changing the values in "YYYYMM" to actually be YYYYQQ, where the last two digits are the number of the quarter (01-04). That doesn't seem to work either. I also tried a simple formula like this:

=calculate(stdevx.p(values(lnl[YYYYQQ]),sum(lnl[amount])),all(lnl[date]))

and it didn't work either. I'm not sure what happens if I have more than one record with the same YYYYQQ. Does the standard deviation formula aggregate based on the first parameter? My goal is to determine the total for each quarter, and then take the standard deviation of those amounts. So just (Jan + Feb + Mar), (Apr + May + Jun), (Jul + Aug + Sept), and (Oct + Nov + Dec) for each year. Do I really need to use the summarize function to limit myself to just these quarterly totals?
 
Upvote 0
I think I have something working. I found a good article on DAX grouping that explains the VALUES and SUMMARIZE functions.

calculate(
stdevx.p(
values(table[YYYYQQ]),
calculate(sum(table[amount]))
),
DATESINPERIOD (
table[date],
ENDOFQUARTER ( table[date] ),
-12,
QUARTER
)
)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,215
Messages
6,123,668
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top