简体   繁体   English

SSRS的不同值之和

[英]SSRS sum of distinct values

I want sum of only unique values in SSRS report.Is there any logic to achieve this. 我只想要SSRS报告中唯一值的总和,是否有任何逻辑可以实现这一点。 this is what something like this sum(distinct value) 这就是这个总和(不同的值)

Thanks 谢谢

Yes. 是。 You use groups. 您使用组。 At the top click the insert menu, then table, then Table Wizard. 在顶部单击插入菜单,然后单击表格,然后单击表格向导。 Pick your dataset and hit next. 选择您的数据集,然后单击下一步。 Now drag the column for the different types of items you want a distinct sum of into the Row Groups section. 现在,将想要不同总和的不同类型项目的列拖动到“行组”部分。 Drag your count column into the Values section. 将计数列拖到“值”部分。 This should automatically turn it into Sum(ColumnName). 这应该自动将其转换为Sum(ColumnName)。 You can click the down arrow to change the aggregate type (if desired). 您可以单击向下箭头以更改聚合类型(如果需要)。 Press next and next and finish. 按next和next完成。 Viola. 中提琴 You have a distinct sum for each specified field. 每个指定字段都有一个不同的总和。

Supposed you have a column named value in your query, you could do the following: 假设您的查询中有一列名为value的列,则可以执行以下操作:

Add an additional column to the query of the dataset: 在数据集的查询中添加其他列:

ROW_NUMBER() OVER (PARTITION BY [value] ORDER BY [value]) AS valueNr

Then, if you already have created a Sum field in the table, change the expression of the textbox to 然后,如果您已经在表中创建了“求和”字段,请将文本框的表达式更改为

=Sum(Iif(Fields!valueNr.Value=1, Fields!value.Value, 0))

Repeat this for every "distinct sum" calculation. 对于每个“不同的总和”计算重复此操作。

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

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