Student T-distribution in DAX - excel

I would like to use the Student T cumulative distribution function & its inverse function in a measure related to a data table in PivotTable Fields.
Excel has a T CDF with T.DIST and its inverse with T.INV. However is it a more or less straightforward to use an equivalent in DAX?
I cannot currently find any answer to my question.
Thanks in advance for your insights!

Related

Calculating the coefficients a and b of an exponential equation in Power Query/M in power BI

I am trying to recreate numbers which I easily calculated in excel and now I would like to have calculated in Power BI. To be more precise I would like to have it in power query/M and NOT in DAX due to later calculations.
To be more specific I would like to calculate the coefficients a and b of an exponential equation exponential y=ae^(bx).
In the following picture, you can see the data and also a graph over the data. Furthermore, the graph also displays a trendline using an exponential function and above the equation is shown y=6,5408e^(0,2834x).
These coefficients are calculated in cell b14 and b15 and the calculations are shown in d14 and d15 (my excel is set to Danish, the English version of a is calculated using ex(index(linest(ln( and b by index(linest(ln( ).
As you can see, to calculate the coefficients, a column with index have been created in column c.
To calculate the coefficients I used the LN() function on a list/array in excel, and the only power query/M function I can find is Number.Ln(), however, it does note take a list as input.
Due to the lack of on LN function in power query/M, I have a hard time calculating this, and I really hope someone has an answer to this!
Thank you in advance !
Kind Regards, Louise
Number.Ln()
Returns the natural logarithm of a number, number. If number is null Number.Ln returns null.
https://learn.microsoft.com/en-us/powerquery-m/number-ln
Also check out
https://www.bookkempt.com/2017/10/simple-linear-regression-in-power-query.html

Replicating Excel averageifs in PowerBI

I'm having difficulty replicating the following Excel calculation in power BI
=IFERROR(AVERAGEIFS(Data!$I:$I,Data!$A:$A,Tables!$C$2,Data!$B:$B,Tables!$E$2,Data!$E:$E,Tables!$B5), "N/A")
I am trying to calculate an average on 3 values, area, period and metric. In power bi using the quick measure it returns either the count of the metric title or the average of the metric, with an additional row for the values that are marked as n/a.
Count of Raw_Score average per metric_ref =
AVERAGEX(
KEEPFILTERS(VALUES('Data'[metric_ref])),
CALCULATE(COUNTA('Data'[Raw_Score]))
)
files / images here
maybe I understood the question wrong, so feel free to correct me, but you are simply trying to calculate an average for different groups, is that so?
First, when working with PowerBI do yourself a favor and forget how Excel works, your life ll be much easier.
Now for the solution.
The trouble is, that your score metric is not a correct data type for average calculation. In Edit Queries, change data type to number (prior step of replacing "N/A" to "" might be required)
(optional step) I would recommend fixing data type of all relevant columns.
With data in correct format, you simply create visualization and slice it with grouping label. Something like this:
Notice the small arrow near the Value-theme_ref field (in your case you should probably substitute it with Raw_Score columns). You simply change the calculation from Sum to Average, which should do the trick.
Once again, I apologize if I misunderstood the question. Feel free to specify.

Excel - Add function to those defined in Pivot Table

Good afternoon!
I've made a Pivot table from the data in the PowerPivot.
I would like to have in my pivot table the AverageIFS function instead of the Average one, because I want to calculate the average not including the registers that have 0. In the picture, the column that I use to calculate the average is Duree_Deplacem (in the picture).
I have found some information about what I need in https://support.office.com/en-us/article/change-the-summary-function-or-custom-calculation-for-a-field-in-a-pivottable-report-ea8945fb-9969-4bac-a16c-4f67b0f7b239, but it only uses the defined functions and doesn't give the option to use other functions. That makes me think it may be impossible. (?).
If you are using PowerPivot to make pivot table reports, it's a big mistake trying to use calculated fields in a pivot table. It's like using a horse to pull a Ferrary.
PowerPivot has its own language called DAX, with which you can write dynamic formulas that are much more powerful and flexible than the calculated fields. But you will need to invest some time to educate yourself - you must understand what you are doing.
Here is an example of a starter tutorial
Once you understand what a Measure is, your problem can be solved as follows:
Average Without Zeros = CALCULATE( AVERAGE(Table[Field]), Table[Field] > 0)
where Table is the name of your table, and Field is the name of the field you are averaging.
If you drop this measure into a pivot table, it will calculate averages correctly, in any pivot table layout.
Once you see how it works, your life will never be the same :)
If you decide to learn DAX and PowerPivot more seriously, I recommend this book to start with:
Power Pivot and Power BI: The Excel User's Guide to DAX

DAX Normal Distribution

I am looking for a function in DAX that acts similarly to the NORM.DIST function in Excel. I have an X value, the mean, and the standard deviation and I am looking to find the cumulative distribution (with an accuracy of at least six sigma).
I've searched through the official list of DAX statistical functions, but I could not find any function that does this. I'm looking for the most economical way to perform this calculation. Is the Bell approximation the best way to go? This would be iterated over a table of about 10,000 rows.
SIGN([X])*0.5*(1-(1/30)*(7*EXP(-([X]^2)/2)+16*EXP(-([X]^2)*(2-SQRT(2)))+(7+0.25*PI()*[X]^2)*EXP(-([X]^2))))^0.5+0.5
Given [X] is already normalized. MAX Error = .0000304
Error:
Compared to previous solution:
http://mathworld.wolfram.com/NormalDistributionFunction.html (14)
=.5*(1+SIGN([X])*(1-EXP(-2*([X])/[Sigma])^2/PI()))^.5)
Worked for me. This may be the fastest way, this may not. Idk.
EDIT
MAX Error = .0031458

How do I define a Standard Deviation function in Pentaho Schema Workbench

I'm building an OLAP Analysis with Pentaho's BI Suite (Community Edition). Many of my measures are standard deviations of the variables in my fact tables.
Does someone has a tip on how to define a Standard Deviation aggregation function in Schema Workbench? Lot's of my jobs could benefit of it.
Thanks in advance!
You could use a MeasureExpression
There is a guide on how to do this in Postgresql here, what is your underlying db?
http://blog.endpoint.com/2009/07/subverting-postgresql-aggregates-for.html
There has long been a request to support custom aggregators, it's not been done yet.
In my case the database has 3 mill rows, the MDX cube has 3124 cells.
So the MDX function would calculate the std dev from the 3124 cell values, whereas a "real" statistician usually would use all 3 mill rows.
To get the statisticians STDDEV, I added a column in the database, being the square of the row value.
Then in Mondrian I defined a new measure, the std dev, as :
square root of ( sum of squared values - (average value * average value))
This has some consequences for hierarchies, but that is another story.
How I'm calculating standard deviations now:
I created an ID dimension, not to explore, just to make sure that Mondrian isn't calculating Standard Deviation of values already aggregated.
Then I created a new Calculated Member using the MDX formula:
Stddev(Descendants([ID_Dimension.ID_Hierarchy],,Leaves),[Measures].[Measure with values to be aggregated]).
Performance sucks.
The idea came from this very old forum post.

Resources