SSRS SUM and IIF statement based on Group - reporting-services

I have a dataset "dsAuditQuestions" which has fields including "Category" and "SuccessCriteriaMet". The latter contains either a "True" or "False" value which I'd like to count as 1 or 0..
I have created a tablix which groups by "Category1".
I'm trying to write an expression in SSRS to calculate the SUM of the 1s for each category.
I've tried many variations but can't get it to work.
=SUM(IIF(Fields!Category.Value="Category1" AND Fields!SuccessCriteriaMet.Value = "True",1,0),"dsAuditQuestions")

Related

How can I keep a running total of a ReportItem Value in SSRS?

I have a tablix in which one column has a value populated accordingly:
=IIF(Month(Fields!THEDATE.Value) <> Month(DateAdd(DateInterval.Day, 1, Fields!THEDATE.Value)),
FIRST(Fields!lot_size.Value, "END_OF_MONTH"),
0)
The tablix is like a calendar and on every last day of the month a default value is placed in that column/cell. What I need to do now is keep a running total of that in another column. If I just use the same formula inside a RunningValue statement I get an error about an aggregate not being able to use the FIRST statement. I have also tried a RunningValue of the ReportItem textbox value.

How to display a SUM Value in a textbox from the another dataset, not from the tablix dataset name

I have two datasets to display in a table. Dataset1 which I named in a tablix is working well but when I get a value from dataset2, it does not display in the textbox.
This is what I've typed as expression:
=IIF(First(Fields!Type.Value, "Dataset2") = "pc", Sum(Fields!Hours.Value, "Dataset2"), 0)
I am expecting a sum of hours worked by pc but it displays 0 in the textbox.
Well I guess your first Type value in the Dataset2 does not have the value pc, thus it will display zero.
If you just want to display the sum of Dataset2 use the following expression:
=Sum(Fields!Hours.Value, "Dataset2")

ssrs expression sum doesn't sum all column

I have a column like:
LEFT_PIN_HEIGHT_MIN
0
0
0
1
1
0
I wrote it to Tablix as below,
=Sum(Fields!LEFT_PIN_HEIGHT_MIN.Value)
I want to sum the fields and result must be "2" but it doesn't sum the column
and writes all the rows to Tablix.
I agree with the previous answer that your first choice ought to be to calculate this in the SQL, but sometimes that is not as practical.
Are you trying to display the column's sum in each row? If so, add the dataset name as a second parameter in the sum function, as in
=Sum(Fields!LEFT_PIN_HEIGHT_MIN.Value,"Dataset1")
Replace "Dataset1" with the name of your dataset. The Sum function you're currently using is defining the sum within the context of each row in your tablix. Adding the second parameter changes that context to return the sum for the entire dataset in each row.
If your tablix is large, this may result in a performance hit, since the expression will evaluate each time it is displayed, hence the preference toward doing it in your dataset query.
I suggest to do It with SQL. Use query to SELECT SUM(LEFT_PIN_HEIGHT_MIN)...
If you want to achieve It by SSRS expression you can do It in following:
Right Click on table1_Details_Group > Group Properties...
In Group on: field provide LEFT_PIN_HEIGHT_MIN click OK
To hide 0 > Right Click on left side of values row > Row Visibility check Show or hide based on an expression then write following expression: =IIF(Fields!LEFT_PIN_HEIGHT_MIN.Value = 0, true, false) click OK
It should work.

SSRS Visibility Hide iif All

Just wondering if it is possible to do the following on SSRS for a textbox visibility (hide), it seems to return an error for me:
=iif(parameters!category.value = "All",True,False)
I have a long list of category so therefore is impossible to list them all, is it possible to the above? I keep getting an error with the above-outlined syntax
I assume the category parameter is multi-select with available values fed by a SQL query. You can use the Count property on the parameter to get the number of selected items and compare that to the number of items returned by the SQL query using the COUNT() SSRS aggregate function with a scope of the dataset. If the number of selected items matches the number of available values then they must be all selected.
So your code would look like:
=IIF(Parameters!category.Count = COUNT(Fields!CategoryName.Value, "CategoryParameterDataSetName"), True, False)
In this case the dataset that contains all of your available values is named CategoryParameterDataSetName and contains a field named CategoryName. Change these values as appropriate.

Show all records/some records based on parameter value

I have stored procedure which returns around 100 rows. One column is Category.
In SSRS, I've created DataSet related to that stored procedure. On Report body I have Tablix, which I relate to DataSet.
Now, I have additional parameter, called FilterColumn, which consist all different categories from dataset, plus one row called "All products".
How to filter tablix based on that parameter to show me whether products from specific categories or all products?
You need to set up a filter similar to the following:
Where the expression is:
=IIf(Parameters!FilterColumn.Value = Fields!Category.Value
or Parameters!FilterColumn.Value = "All products"
, "Include"
, "Exclude")
This matches the row Category based on the parameter value, or, if the value = All products, will include all rows.
As mentioned in the comments and the other answer, this is possible in the SP too, but since it seems to be specifically to demonstrate the functionality this should do the trick at the report level.
I have created some solution and worked for me:
In Expression field, I put first expression:
1. Iif(Parameters!FilterColumn.Value = "All", 1, Fields!Category.Value)
In Value field, I put second expression:
2. Iif(Parameters!FilterColumn.Value = "All", 1, Parameters!FilterColumn.Value)
So, when I choose "All" value in parameter, then first expression will result 1, and second expression will result 1, and i have 1 = 1 which is true for all rows, and I got all rows in table.
When I choose specific category from parameter, then in first expression result will be Fields!Category.Value and in second expression will be Parameters!FilterColumn.Value. Simple, I got Fields!Category.Value = Parameters!FilterColumn.Value, or just give me rows where category is that choosen in parameter.
Pass the Additional Parameter to your store procedure, so you send data that is already sorted to your report. This will avoid multiple Tablix created depending on your parameter selection.