问题
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))
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/55746727/i-want-to-count-the-number-based-on-a-field-injected