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

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

问题描述

我正在尝试计算 PowerBI 中一组值的标准偏差,但我被卡住了.表中有两列(天数和计数).这是运输车道的频率分布.天数从 1 到 100,计数是这些天数的发货数量.

计算频率分布的标准差的公式非常简单:sqrt(sum(fx * (x - avgx)^2))/sum(fx)) 但 Dax 让我非常头疼.任何帮助将非常感激.谢谢.

解决方案

我从

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

并且度量创建如下,棘手的部分是利用

附: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天全站免登陆