I want to count the number based on a field inject

2019-08-23 01:10发布

I am working on SSRS report. I have a report where the user inserts the login, start date and end date. I want to count the number of rows of WarantyColumn that have the value 1 for the user injected between start date and end date.

Count(iif(Fields!TextField.Value=, Fields!TextField.Value, Nothing))

2条回答
甜甜的少女心
2楼-- · 2019-08-23 01:15

Create a new column, let's call it warrantycolumncount. For this column, set expression as

IIF(Field!warrantycolumn.Value = 1, 1, 0)

This expression will set 1 where your condition matches and 0 where condition does not match.

If you wish you can hide this column for you final report as well

Now at the bottom of your tablix you can create row Total

To add totals for a row group

  • In the tablix data region row group area, right-click a cell in the row group area for which you want totals, point to Add Total, and then click Before or After.
A new row outside the current group is added to the data region, and then a default total is added for each numeric field in the row.
查看更多
姐就是有狂的资本
3楼-- · 2019-08-23 01:15

You should just be able to use something like.

=SUM(IIF(Fields!WarrantyColumn.Value = 1,1,0))

This will work inside a tablix that is bound to your dataset. If you need to do the same outside of the tablix then you have to provide scope, so something like.

=SUM(IIF(Fields!WarrantyColumn.Value = 1,1,0), "myDatasetName")

**Note: ** oy must put the dataset name in quotes and it is case sensitive so it must match the name exactly.

查看更多
登录 后发表回答