Report Builder SUM IIF - More than 1 DataSet - reporting-services

I am trying to add the following expression to a TextBox on a Report Builder report using the following code:
=SUM(IIF(Fields!TaskDescription.Value,"DataSet1") = "Running", 1, 0)
I have more than 1 dataset which I think is causing the issue, but the above gives me the following error message:
The scope parameter must be set to a string constant that is equal to
either the name of a containing group, the name of a containing data
region, or the name of a dataset.
What am I doing wrong?

The Scope, in your case the DataSet, need to be the last parameter in the aggregate, i.e. after the IIf:
=SUM(IIF(Fields!TaskDescription.Value = "Running", 1, 0), "DataSet1")
i.e. =Sum(<Expression>, <Scope>)
The expression counts the occurrences of the value Running in the TaskDescription column in the DataSet1 DataSet.
Edit after comment
A quick test showing the expression in action. A simple DataSet with your column:
I've just added a textbox to a blank report with the above expression:
Works as expected on the sample data:

Related

SSRS IIF Expression- IFF not Declared?

I'm trying to write an IFF statement in SSRS report inside Visual Studio.
For this scenario, In my data I have the following two fields, MaxCompareDateLapse and MaxCompareDateLapse2. Both of these return integer values. I also have a parameter which has the following values available for the use to select: 3, 6, 9, 12
I'm entering an IFF statement in an expression and I'm getting back the error 'The Value Expression for the textrun 'MaxCompareDateLapse.Paragraphs[0]' contains an error: [BC30451] 'IFF' is not declared. It may be inaccessible due to it's protection level'
I've tried the following two expressions and they both give me back the same error. The first one below is ultimately what I want to get it, and the second one I simplified a bit to see if it would work but I still get the error.
Code #1
=IFF(Fields!MaxCompareDateLapse.Value <
Parameters!pMonthsNoActivity.Value, Fields!MaxCompareDateLapse2.Value,
IFF(Fields!MaxCompareDateLapse.Value >=
Parameters!pMonthsNoActivity.Value, Fields!MaxCompareDateLapse.Value))
Code #2
=IFF(Fields!MaxCompareDateLapse.Value <
Parameters!pMonthsNoActivity.Value,
Fields!MaxCompareDateLapse2.Value,
Fields!MaxCompareDateLapse.Value)
So for example 1. If MaxCompareDateLapse =1, Parameter = 6, and MaxCompareDateLapse = 20, then 20 would be returned. If MaxCompareDateLapse = 7, Parameter = 6, and MaxCompareDateLapse = 5, then 7 would be returned
Thanks in advance - still pretty new to this stuff
You should replace the IFF with IIF as that is the correct syntax.
Refer to foll. example:
=IIF( Expression to evaluate,
what-to-do when the expression is true,
what-to-do when the expression is false )
You can nest using the 2nd and/or 3rd arguments based on your requirements. Example if you want to nest another IIF check if the above expression is false:
=IIF( 1st Expression to evaluate,
what-to-do when the 1st expression is true,
IIF( Another Expression (2nd) to evaluate,what-to-do when that 2nd expression is true,what-to-do when that 2nd expression is false )
)
Hope this helps.

Why my parameter shows me an error Failed to evaluate the FilterValues of the DataSet?

I want to get available values from query in my ssrs report parameter.
I set Get values from a query
DataSet : name of my dataset#
Value field: my field
Label field : my field
To get an idea i will show you what i mean:
For expected results : I want to use my parameter as multie value parameter..
Your expression should be something like this and you need to add this expression by pressing fx next to value rather than directly adding it.
=IIF(Parameters!RootPoint.Value(0)="",Fields!C_RootPoint.Value,Parameters!RootPoint.Value(0))
also if you are trying to check if your first parameter value is null then you should try like below
=IIF(Isnothing(Parameters!RootPoint.Value(0)),Fields!C_RootPoint.Value,Parameters!RootPoint.Value(0))

Condition to be given for Option set value in a Drill Down Report

Hi I have a an option set field named as Stage . The schema name for the code is new_stage .
The option values for Code field are as follows:
Label -> Mobile - Value -> 1
Label -> Telecom - Value -> 2
Label -> Others - Value -> 3
I have got the Sum of each Option values of Stage in each Columns of a table in a report and trying to pass a parameter in each Sum of the option value to go to a Drill down sub report.
The expression I used to get the sum of each Option set value of a Stage field in each column is Sum(IIf(Fields!new_StageValue.Value = "1", 1, 0), "DataSet1") .
In the Action tab of the Option set value's Sum text box, I gave the Sub report which I wanted to and gave the parameters.
I have mapped the From, To and Stage parameters as below:
From - [#From]
To - [#To]
Stage - Expr
where the Expr contains Sum(IIf(Fields!new_stageValue.Value = "1", 1, 0), "DataSet1") .
I have passed the Integer parameter as you can see new_stageValue.Value and I have set the Integer as the Data Type in the Sub report's Stage parameter.
When I saved and generated the main report, I have got the count. When I clicked the count,it went to the sub report but it did not fetch me the records.
Help me as where I am missing! Thanks in Advance!
Main Report:
Main Report's field's condition expression

IIF Statement Not Returning a Value in SSRS

I'm very confused by this situation, i've written quite a few IIF statements and always get them to work. I have two columns in my dataset called CATEGORY and PCT, what i'm trying to do is return the PCT value for only one specific value in CATEGORY.
For example, I have the following table of data
Category PCT
A .50
B .75
I have placed a textbox on my report and have written the following expression to return the PCT value if Category = B, like so:
=IIF(Fields!Category.Value = "B", Fields!PCT.Value, " ")
For some reason this expression returns empty every single time. When I just put Fields!Category.Value in the textbox as a test then the value A returns which is as expected.
I'm really thrown-off by this and I know i'm missing something very simple - can someone help?
Its important that we understand the context of the textbox as the expression seems valid.
If you placed a single textbox on your report and used your above expression (with references to the datasets) ONLY the first row of your dataset will be evaluated. In which case the expression will always evaluate to the same result.
Can you confirm that the control you are using is indeed a textbox? If it is then i believe you do need a reference to the dataset and the expression will look more like this:
=iif(First(Fields!Category.Value, "datasetName") = "B", First(Fields!PCT.Value, "datasetName"), " ")
This would only evaluate the first row in your dataset.
If you were to do this in a tablix using your original expression then it should work.

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.