Forum Discussion
Standard deviation across columns
I'm not sure why you would want to calculate stdev for rows (across columns). If you want to do it, you have to change the model and arrange your data in such a way that your rows become columns (columns become rows) and then you can use the standard function of DAX, STDEV.S – DAX Guide. Functions in DAX are designed to work with columnar databases (which PBI uses behind the scenes), not row data.
If you really insist, you can do it but it'll be a very messy formula and not dynamic. Not recommended at all.
The proper way is to just transform the data into:
table T:
reading, value
reading1, 1
reading1, 2
reading1, 1
...
reading2, 1
reading2, 4
...
Once you've got this data (which will accomodate any number of "your columns" dynamically) it's dead easy to do it. This measure will do it: [STD] = STDEV.S( T[Value] ). When you start slicing by the reading column, you'll get the stdev for each and every reading across the columns in your original table.
- AjinMi5 years agoRegular Visitor
But how to do if I need std across particular columns.
- daxer-almighty5 years agoSolution Sage
Transform the model accordingly or... you'll have to type the usual formula by hand using the column names. I told you it's tedious and in my view incorrect. If you are creating a calculated column, you'll have to do something like:
var Mean_ = ( T[Col1] + ... + T[ColN] ) / N var Var_ = ( ( T[Col1] - Mean_ )^2 + ... + ( T[ColN] - Mean_ )^2 ) / ( N - 1 ) return Var_^(0.5) // You know that you'll have to write out // all the columns in the above formula // and replace the "...", right? Told you // it would be tedious and not scalable...