SQL Server 2012
Visual Studio 2010
Dataset being used is called Performance
Formulas
ACB = Average Capital Base
IRR = Internal Rate of return = Total Gain/ACB
Contribution = ACB/Sum(ACB)*IRR
我正在试着计算投资贡献。下面是一个计算示例。
Account Total Gain ACB IRR Contribution
ABC 2,000.00 20,000 10% 6.67%
DEF 2,000.00 10,000 20% 6.67%
total 4,000.00 30,000 13.33% 13.33%
总内部收益率和总贡献总是相等的
请注意,贡献是单个行ACB乘以ACB的总和,然后乘以单个行IRR。
我有以下报告。我的问题是,由于嵌套聚合,我不能让subtotalling和problem工作。我也不确定如何确定正确的数据作用域。
IRR和IRR小计表达式(工作)
=Fields!TotalGain.Value/Fields!ACB.Value
=Sum(Fields!TotalGain.Value)/Sum(Fields!ACB.Value)
尝试进行贡献计算(得出错误的数字)
=Fields!ACB.Value/Sum(Fields!ACB.Value, "Performance")*Fields!IRR.Value
尝试获得贡献的小计和总计(尽管数字是错误的)
=sum(Fields!ACB.Value/Sum(Fields!ACB.Value, "Performance")*Fields!IRR.Value)
我得到了这个错误
Error 3 [rsInvalidNestedDataSetAggregate] The Value expression for the text box ‘Textbox29’ has a nested aggregate that specifies a dataset scope. Inner aggregates cannot specify a dataset scope. F:\Automater\SSRS\Reports_2012\PerformanceSample2.rdl 0 0
我意识到错误与试图对已经求和的值求和有关,但这正是计算所需的。
发布于 2013-07-07 14:07:30
根据你上面的描述,你似乎正在计算出对Classification水平的贡献,例如股票,固定收益。
因此,在计算详细信息行的总ACB时,您需要计算出该特定Classification作用域中的总。
考虑一些简化的数据:
我将其称为DataSet Performance,并基于它构建了一个报告:
对于行级Contribution,我使用了以下表达式:
=Fields!ACB.Value / Sum(Fields!ACB.Value, "Classification")
* (Fields!TotalGain.Value / Fields!ACB.Value)
这里,SUM
表达式的作用域是组级别。
对于小计,我使用表达式:
=Sum(Fields!ACB.Value) / Sum(Fields!ACB.Value, "Classification")
* (Sum(Fields!TotalGain.Value) / Sum(Fields!ACB.Value))
在我看来,这两个表达式似乎给出了预期的结果:
你会注意到,因为在组级表达式中,Sum(Fields!ACB.Value)
等同于Sum(Fields!ACB.Value, "Classification")
,所以实际上可以简化为Sum(Fields!TotalGain.Value) / Sum(Fields!ACB.Value)
,即IRR,这也是我们所期望的。
如果您需要计算出所有Classifications,的总和,即总计,则必须在上面的表达式中将"Classification"
更改为"Performance"
。
希望这能帮助你得到你想要的结果。
发布于 2013-07-08 00:08:02
伊恩·普雷斯顿
你的回答让我走上了正确的道路,并且非常接近于让我达到总和。解决方案。因此,我将其标记为正确。然而,我想添加一些额外的反馈。您是对的,我需要通过行级作用域指定行,该作用域可以针对不同的分类级别进行切换,称为ClassificationMemberName
下面是我的行级贡献公式
=Fields!ACB.Value/Sum(Fields!ACB.Value, "ClassificationMemberName")
* (Fields!TotalGain.Value/ fields!ACB.Value)
由于小计的原因,我需要将值乘以2才能得到正确的结果?然而,这只适用于资产级别的分类。如果我按总投资组合分类,价值就翻了一番。
=sum(Fields!ACB.Value, "ClassificationMemberName")/
Sum(Fields!ACB.Value, "Performance")
*
sum(Fields!TotalGain.Value, "ClassificationMemberName")/
sum(fields!ACB.Value, "ClassificationMemberName")*2
如果你想明白我的意思,我附上了rdl。我非常感谢你的努力。
这是rdl
https://dl.dropboxusercontent.com/u/29851290/PerformanceSample2.rdl
https://stackoverflow.com/questions/17508251
复制