I have a report with a dataset that has a column with booleans. In the table footer I want to display x / y
where x
is how many rows that were true
and y
is how many rows there was total.
Currently I have this:
=Count(Fields!Transfered.Value).ToString() + " / " + CountRows().ToString()
But the first becomes same as the last part. I then tried this:
=Sum(Fields!Transfered.Value).ToString() + " / " + CountRows().ToString()
But that generates an error, which I guess I can understand. I thought that if I converted the booleans into numbers where true is 1 and false is 0, then it could work out nicely. But how can I do that? Or is it a smarter way to do this all together?
Update: Have now also tried
=Sum(CInt(Fields!Transfered.Value)).ToString() + " / " + CountRows().ToString()
And got a negative result... O.o
Also found a way that worked, which I posted as an answer. But I won't accept it as an answer yet incase someone has a better way to do this =)
Let me show you how I add the total number of rows in a SSRS table. I start by going to the Design layout tab. Next, select the table as shown in the above image. As I mentioned earlier, I want the text box to appear above the table in the left-hand corner.
The function Countifs can often be implemented with an and condition in the case expression. The function counta can be implemented with a case expression as well. For that, SQL makes a distinction between empty strings and the null value.
To do so first, goto the Yearly Income Total Column (Education Level Total Row -> Yearly Income Column), and right-click on it will open the context menu. From the context, Please select the Add Total option as shown in the below screenshot. Let me open the Preview tab to check the Grand Totals at the details level.
Running Total is the running aggregate of all non null numeric values. RunningValue function can be used in SSRS To create Running Total Column.
I can tell you why things went wrong...
To avoid the extra IIF, you could use negate the sum of all the -1s
= -Sum(CInt(Fields!Transfered.Value)).ToString() + " / " + CountRows().ToString()
In the end, either solution would be OK and both are equally kludgy
Figured out a way to do it, although there is probably a better more clear and logical way...
=Sum(IIF(Fields!Transfered.Value, 1, 0)).ToString() + " / " + CountRows().ToString()
I came across this today and at least verified that I wasn't the only one that got a negative sum value for bools out of SSRS. Thanks.
My solution was to use ABS for absolute value. I like that better than just negating the expression solely because it's easier to see visually where the '-' might be missed if you're not careful in reading the expression.
but it's essentially the exact same thing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With