I am currently writing a SSRS report, my main data is populated into a table already by SQL coded, I have added another table below to summarise the data.
the issues i am having is when i enter an expression with more than 1 if the results given are not as expected
the expression i have is below:
=iif(reportitems!country1.Value = Fields!country.Value and Fields!Loc_Quality.Value = "GOOD",sum(Fields!Qty_Ordered.Value),nothing)
giving the resultant below
[![results given ][1]][1]
i should be expecting
[![expected results][2]][2]
is there something i am missing here or am i just trying to do something that isn't possible logically ?
[1]: https://i.stack.imgur.com/vQ2vF.png
[2]: https://i.stack.imgur.com/FAwtQ.png
Try this..
=SUM(
IIF(
reportitems!country1.Value = Fields!country.Value and Fields!Loc_Quality.Value = "GOOD",
Fields!Qty_Ordered.Value,
Nothing
)
)
Related
I am new to SSRS and have a SUM(IIF question.
My data set contains four columns: Date, GroupID, PlanPaid, and NetworkIndicator.
Here is an example of the data set:
I am trying to SUM the [PlanPaid] amount when [NetworkIndicator] = "In Network".
However, I need this amount broken up by the [Date]. I tried accomplishing this by creating the expression:
=Sum(IIf(Fields!NetworkIndicator.Value = "In Network"
, Fields!PlanPaid.Value
, Nothing)
, "Claims_Rolling12")
But this expression returns the same amount (total) across all [Dates]. How do I break it up so that it is grouped by the correct [Date]?
Here is a photo of my Tablix and my current Groups: [Tablix and Groups]
And here is a photo of the output: [Output]
You haven't said where you want this sum to appear, so the answer here might not work. If it doesn't then edit your question to show what you expect the output to look like based on your sample data.
I'm assuming here that you want to add a new column to the report that shows "In Network total" by date.
The easiest way to do this is to add a row group that groups by date, then within this group you can use a simple expression, like the one you tried, but without specifying the scope.
=SUM(IIF(Fields!NetworkIndicator.Value = "In Network", Fields!PaidPlan.Value, Nothing))
This expression will only sum rows that are within the current scope, in this case the scope will be the row group you created to group by dates.
As IO said, if this is not helpful, edit your question and show what you expect your end result to look like, based on the sample data you supplied and then I can look at it again.
I'm New to SSRS.
Im trying to create a report where i need to group by [DATA Flag] column which is working fine ,but once the data is grouped i need to set the DATA FLAG ="TotalCancellations" and there is another column CancellDays which i need to set it as <120 .
I tried
Option 1:-
So to achieve this i have added TWO filters one with
Expression : DATA FLAG
Operator =
and Value as TotalCancellations
and the other filter as follows
Expression : Cancelldays
Operator =
and Value as < 120
But its not working and giving empty result,i have records with Cancelldays <120
Option 2 :-
Right click on Group and in General Tab ,Group on Expression as below ]
Fields!DFlag.Value = "TotalCancellations" AND Fields!DFlag.Value <120
which didnt work :(
this is similar to writing having clause in SQL i believe but im not getting how to implement that here in SSRS.
i can add in SQL Query but its already a huge query with lot of unions so please suggest me if there is any way i can implement here in SSRS
Im using Matrix in SSRS 2008
Adjusting the syntax for your option 1 is probably the easiest solution. In the Group Properties, under the Filters section, enter these two filters:
Expression: [DFlag] (Text)
Operator: =
Value = TotalCancellations
Expression: =Sum(Fields!CancelDays.Value) [enter this in the expression builder] (Integer)
Operator: <
Value: 120
Putting all the filters in a single expression, like your option 2, can be useful if you need to filter by one criteria OR another.
Below are the filer expressions
and this is how group by is
The filter should be implemented at the tablix level, not at the group level.
I have been working on ssrs and tried to do the following statement. I am using data from 2 datasets and there is no way I can merge them into one (I tried that when I first had this error). Code:
=Sum(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
This code gives the error: The Value expression for the text box has a nested aggregate that specifies a dataset scope. Inner aggregates cannot specify a dataset scope.
I have also tried a different variation of this code which is as follows:
=(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
I just got rid of the sum at the beginning. But this time I had a different error: Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case
Hope someone can help :)
Cheers
Your expression is a bit wrong.
=Sum(iif(Fields!Year.Value = Max(Fields!Year.Value) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0))
Your Sum is outside and is covering the two fields which is not on the same dataset. You should assign Sum for each of them since they are from different dataset.
Try this:
=iif(Sum(Fields!Year.Value) = Max(Sum(Fields!Year.Value)) - 1 , Sum(Fields!PersonCount.Value, "RetCust"), 0)
Note: I haven't tested the Max(Sum(.... if that's correct.
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.
I've written a report for SSRS and Im using dataset filters with expressions to filter the report info. I seem to either have this expression wrong or the filter is not working correctly:
=IIf(Parameters!DoctorID.Value = "All" Or Parameters!DoctorID.Value = "", "*", Parameters!DoctorID.Value)
What I want to accomplish with the above code is if DoctorID = ALL or "" (blank) then I want to omit it from the filters so I return information for all doctors. However, whenever the value of DoctorID = ALL, I'm returning no rows what so ever. It should be the case that i'm getting ALL rows since DoctorID is not a specific number.
Does the "*" (star) not denote an omitting of that filter? Am I doing something wrong here?
Thanks!
The filter formula you provide is only half the equation: what is the operator and what are you comparing this to? And yes, I haven't seen SSRS use asterisk as a wildcard.
Consider putting your filter into the query for the dataset. The SQL WHERE clause can get pretty powerful. I would write your filter into the query as
...
WHERE
#DoctorID = 'All' OR #DoctorID = ''
OR #DoctorID = myTable.DoctorID
This will also let you move to a multiple value parameter pretty easily.