从Power BI中的值和频率列计算标准偏差 [英] Calculating the standard deviation from columns of values and frequencies in Power BI

查看:1141
本文介绍了从Power BI中的值和频率列计算标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在PowerBI中计算一组值的标准偏差,但我遇到了麻烦。表格中有两列(天数和计数)。这是运输车道的频率分布。天数从1到100,计数是花费这些天数的发货数。



用于计算频率分布的标准偏差的公式非常简单:sqrt(sum(fx *(x-avgx)^ 2))/ sum(fx ))但是达克斯让我头疼不已。任何帮助将非常感激。谢谢。

解决方案

我从



转换为Power BI等效项并满足您的天数要求:





然后按如下所示创建度量,棘手的部分是利用



PS Power BI实际上具有一些用于计算标准偏差的内置功能,例如 STDEVX.P ,但是在这种情况下,它没有那么有用。随时检查一下。


I am trying to calculate the standard deviation of a set of values in PowerBI and I am stuck. There are two columns in a table (days and count). This is a frequency distribution of a transportation lane. Days goes from 1 to 100, count is the number of shipments that took those number of days.

The formula to calculate the standard deviation of a frequency distribution is pretty straight forward: sqrt(sum(fx * (x - avgx)^2))/sum(fx)) But the Dax is giving me a massive headache. Any help would be much appreciated. Thanks.

解决方案

I took the example from the Standard deviation Wikipedia page as sample data.

Converted to Power BI equivalent and fit your requirement as days and count:

And the measure is created as follows, the tricky part is to make use of the SUMX function. I deliberately break down the intermediate steps with VAR to make it more clear.

st_dev = 
VAR x_sum = SUMX(Lane, Lane[Days] * Lane[Count])
VAR x_count = SUM(Lane[Count])
VAR mean = x_sum / x_count
VAR dev_sq_sum = SUMX(Lane, POWER(Lane[Days] - mean, 2) * Lane[Count])
RETURN SQRT(dev_sq_sum / x_count)

Result:

P.S. Power BI actually has some built-in functions for calculating standard deviation, e.g. STDEVX.P, but it's not that useful in this case. Feel free to check it out though.

这篇关于从Power BI中的值和频率列计算标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆