基于表达值的 SSRS 总计
SSRS Total based on Expression Value
我正在尝试创建一个基于计算的总数以提供毛重。现在,在有人建议(修改 SQL 以给出结果,然后在 SSRS 中对其进行总计)之前,这是来自我无权访问的动态 AX 查询。这是我的报告
给出结果
以红色突出显示的总数是错误的(如果将行加起来应该是 18043.25)。我通过右键单击毛重表达式并消失了 'Add Total'。
毛重表达式(行级别)
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value)
Sum 位非常简单,只是将净重和 taraweight 相加,但随后需要添加托盘重量,这取决于它是否是 pallecon。总的好像是加了IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value
部分仅一次,而不是对每一行进行评估和求和。我尝试将表达式包装在另一个 SUM 中,但是我得到的总重量约为 23300,这太高了。正如我之前所说,我应该得到 18043.25。如何根据另一列的总计表达式进行总计?谢谢!
* 更新 * 总表达测试
(test1) =SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + RunningValue(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), Sum, "Group1") = 23323.22
(test2) =RunningValue(SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 3267881.87
(test3) =RunningValue(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 23323.22
经过大量测试后,我相信我在分组的某个地方遇到了问题...我认为这应该能给出我所追求的整体表达方式。如有不妥请指正
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + RunningValue(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 23323.21805
太高了。我 运行 表达式本身给了我大约每行 33 总共 1056 所以我不知道额外的是从哪里来的...
* 进一步更新 *
我想我已经找到与此表达式有关的问题:
IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, (Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value))
每行 33 公斤。
不过SUM(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, (Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value)))
在总字段中给出 6336。我应该得到 33 * 32 行 = 1056。
多出来的5000是哪来的?!?!?!?
您的括号表明您的 IIF 语句只应添加一次。
为清楚起见简化您的字段名称
=SUM (
A * (
B + C
)
) +
IIF(
D, E, F + G
)
或者更简单
SUM ( X ) + conditional
当它出现时你想要
SUM ( X + conditional )
不是这样吗?
我的同事想出了一个替代解决方案。仍然不确定为什么另一个不能正常工作,但这个有效!
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + (Sum(IIf(Fields!palletTypeId.Value = "Pallecon",1,0)) * Max(Fields!PalleconWeightKg.Value))+(CountDistinct(Fields!wMSPalletId2.Value) - Sum(IIf(Fields!palletTypeId.Value = "Pallecon",1,0))) * (Max(Fields!BluePalletWeightKg.Value) + Max(Fields!PackagingWeightKg.Value))
我正在尝试创建一个基于计算的总数以提供毛重。现在,在有人建议(修改 SQL 以给出结果,然后在 SSRS 中对其进行总计)之前,这是来自我无权访问的动态 AX 查询。这是我的报告
给出结果
以红色突出显示的总数是错误的(如果将行加起来应该是 18043.25)。我通过右键单击毛重表达式并消失了 'Add Total'。
毛重表达式(行级别)
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value)
Sum 位非常简单,只是将净重和 taraweight 相加,但随后需要添加托盘重量,这取决于它是否是 pallecon。总的好像是加了IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value
部分仅一次,而不是对每一行进行评估和求和。我尝试将表达式包装在另一个 SUM 中,但是我得到的总重量约为 23300,这太高了。正如我之前所说,我应该得到 18043.25。如何根据另一列的总计表达式进行总计?谢谢!
* 更新 * 总表达测试
(test1) =SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + RunningValue(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), Sum, "Group1") = 23323.22
(test2) =RunningValue(SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 3267881.87
(test3) =RunningValue(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value) + IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 23323.22
经过大量测试后,我相信我在分组的某个地方遇到了问题...我认为这应该能给出我所追求的整体表达方式。如有不妥请指正
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + RunningValue(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value), SUM, "Group1") = 23323.21805
太高了。我 运行 表达式本身给了我大约每行 33 总共 1056 所以我不知道额外的是从哪里来的...
* 进一步更新 *
我想我已经找到与此表达式有关的问题:
IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, (Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value))
每行 33 公斤。
不过SUM(IIF(Fields!palletTypeId.Value = "Pallecon", Fields!PalleconWeightKg.Value, (Fields!BluePalletWeightKg.Value + Fields!PackagingWeightKg.Value)))
在总字段中给出 6336。我应该得到 33 * 32 行 = 1056。
多出来的5000是哪来的?!?!?!?
您的括号表明您的 IIF 语句只应添加一次。
为清楚起见简化您的字段名称
=SUM (
A * (
B + C
)
) +
IIF(
D, E, F + G
)
或者更简单
SUM ( X ) + conditional
当它出现时你想要
SUM ( X + conditional )
不是这样吗?
我的同事想出了一个替代解决方案。仍然不确定为什么另一个不能正常工作,但这个有效!
=SUM(Fields!qty.Value * (Fields!NetWeight.Value + Fields!TaraWeight.Value)) + (Sum(IIf(Fields!palletTypeId.Value = "Pallecon",1,0)) * Max(Fields!PalleconWeightKg.Value))+(CountDistinct(Fields!wMSPalletId2.Value) - Sum(IIf(Fields!palletTypeId.Value = "Pallecon",1,0))) * (Max(Fields!BluePalletWeightKg.Value) + Max(Fields!PackagingWeightKg.Value))