简体   繁体   English

基于另一列中不同值的平均值

[英]Average based on distinct values in another column

For my project I need to create a bar-chart where category axis is the average of an aggregated sum and value axis is rowcount().对于我的项目,我需要创建一个条形图,其中类别轴是聚合总和的平均值,值轴是 rowcount()。 I can't find a way to calculate the average of an aggregated sum directly in the bar-chart.我找不到直接在条形图中计算总和平均值的方法。

Here you can find the dxp file with steps required to calculate the final value ( 85,26 ). 在这里您可以找到包含计算最终值 ( 85,26 ) 所需步骤的 dxp 文件。

I came to a solution using the calculate columns (highlighted in the dataset attached), but I need to calculate it directly in the bar-chart so it will change when filters are applied.我使用计算列(在附加的数据集中突出显示)找到了一个解决方案,但我需要直接在条形图中计算它,以便在应用过滤器时它会发生变化。

I tried to explain better.我试着解释得更好。 My KPI is calculated using the following formula:我的 KPI 是使用以下公式计算的:

Sum([Weight]) OVER ([Period],[ID Player],[Player Type],[ID Game],[Player Role])) OVER ([ID 
Player],[Player Type],[ID Game],[Player Role])>

The average is done on the following values:对以下值进行平均:

(83,50 83,50 83,50 83,50 83,50 83,50 83,50 83,50 86,14 86,14 86,14 86,14 86,14 86,14 86,14 86,14)/16 = 84,82 (83,50 83,50 83,50 83,50 83,50 83,50 83,50 83,50 86,14 86,14 86,14 86,14 86,14 86,14 86,14 86,14) /16 = 84,82

So I tried to add DISTINCT but the result was still incorrect since the average is done for the following values:所以我尝试添加 DISTINCT 但结果仍然不正确,因为对以下值进行了平均:

(83,50+86,14)\2 = 84,82 (83,50+86,14)\2 = 84,82

The average should be based on distinct values from "Period" column so平均值应基于“期间”列中的不同值,因此

(83,50+86,14+86,14)\3 = 85,26 (83,50+86,14+86,14)\3 = 85,26

Can anyone help me to find a formula to obtain the last average?谁能帮我找到一个公式来获得最后的平均值?

Thanks in advance!提前致谢!

EDIT1: I tried a formula that's close to the suggestion in the comments: EDIT1:我尝试了一个接近评论中建议的公式:

Sum([Weight] * [Score]) OVER ([Period],[ID Player],[Player Type],[ID Game],[Player Role]) / Sum([Weight]) OVER ([Period],[ID Player],[Player Type],[ID Game],[Player Role])
,null)) OVER ([ID Player],[Player Type],[ID Game],[Player Role])

But it will do the average taking just first values for each period (60+97+97/3=84,67)但它会取每个周期的第一个值的平均值 (60+97+97/3=84,67) 在此处输入图像描述

Not sure how you have set up the visualisation, but something like the following formula might work不确定您是如何设置可视化效果的,但是类似以下公式的东西可能会起作用

Avg(case when Rank(RowId(),[Period])=1 then [final Score] end)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM