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.
Related
I saw the post on WHERE clause in SSRS expression. I am also trying to do a where clause, but in a different way. I need to show ItemDesc when ItemId = 4. I set a parameter so that it will always equal 4 for this cell. Now I just need the matching description field. I cannot hard code it because the description may change one day. Is there a way to associate the two fields?
=IIF(Parameters!ItemID_4.Value = 4, Fields!ItemDesc.Value,"")
I am converting from Crystal Reports to SSRS. This first image is the output from CR. I only need to show that ItemDesc in that top left cell.
This next image is from SSRS. It is not limiting the descriptions. It seems to be doing what my expression is saying. ItemID = 4, so display all ItemDesc values but the two fields are not associated right now. I need it to only show the matching value.
Thank you for your help.
I cannot hard code it because the description may change one day.
You are hard coding the parameter anyway by trying to do it that way. I don't think you need a parameter to achieve the result unless you are restricted from adjusting the dataset query.
If you are using an embedded SQL query for your dataset, I would just put a filter in WHERE clause: WHERE ItemID = 4
Another way if you can't adjust the query is to go to Report Data view > Right click on the dataset for your table, "Dataset Properties" > go to the "Filters" tab and add a filter with these settings: Expression = ItemID, Operator = "=", Value = "4" (or "#ItemID" if you want to keep your parameter).
So I have a multiple value parameter than contains 3 options. >250K, <250K, >2M.
I also have a table that consists of multiple columns.
. Because the parameter is a multivalue, i am having difficulties filtering the dataset.
I need to filter the dataset by checking, (if > 250K is selected, filter the dataset accordingly), (if < 250K is selected, filter the dataset accordingly) and (if > 2M is selected, filter the dataset accordingly).
I was told to use a join and split on the parameter within the (>250K condition, then do a contains to see if it contains any of the parameter values) but I am not as advanced in my knowledge of coding to be able to do that.
Any Suggestion? Thanks in Advance
I previously tried the method below but then i came to realise that it wont work because the parameter is a multi value.
I know its been a while since you raised this, you were on the right track but all you should need to do is add a filter to the Tablix on the field you will be filtering, use the 'in' operator and in the Value type [#Yourparametername] the square brackets and case sensitivity are important. Also ensure the expression type is correct, in your case it looks like you are using Integer. The image should help.
If you want to use multi-parameters, In the dataset, you can read parameter value using JOIN.
Example:
If you want to read multiple values for #MyParamter in a dataset given in the following example:
Dataset Parameters
you need to use =JOIN(Parameters!myMultiParamter.Value,",") as an expression to read all selected values in CSV form.
Expression
Now the #ParameterValues param has all selected values as comma separated values and you can use them in your dataset code as per design requirements.
Note: It's not necessary to use a comma but u can use anything you want to separate values.
Your sql query where should look like
Where
(
(0 IN (#Parameter) AND ValueColumn<250000)
OR
(1 IN (#Parameter) AND ValueColumn>=250000)
OR
(2 IN (#Parameter) AND ValueColumn>=2000000)
)
One parameter
Two parameters
All parameters
Once you return the value you can also use charindex or patindex* and look for where the value in your where clause is a pattern where the index number is > 0 . For instance if the returned string from SSRS is '01,02,03' and then your where clause has something like this right(field, 2) which would result in value '03'. you change your where clause to be where patindex('%' + right(field, 2) + '%', #returnedstring) > 0 which will give you results. The keeps you from having to parse apart the #returnedstring parameter in your sql code.
(1).In my ssrs report I have 2 queries which i need to put in my dataset.
Based on a dropdown parameter I want to select which query to run.
Is it Possible to do so? Please, help me out.
Ex.
I
If (Parameters!sFlag.Value == "0")
{ Query1}
else
{Query2}
(2).Also based on same parameter i want to select fields in a textbox.
Ex.
=I
If(Fields!IsFlag.Value="0" , Fields!Field3.Value, Fields!Field18.Value)
I am using Informix .
I searched a lot but couldnt find anything appropriate as this thing I have done with sql query but when I apply the same with Informix it doesnt work.
Assuming both queries return the same fields and use the same connection then you could union them together using the parameter to control which returns data. I know that the MSSQL optimiser will effectively not bother running the non true half of the query, not sure about Informix. The result is that you get the values from the first query when the sFlag parameter is "0" and from the second query when its "1".
SELECT 1 as Value WHERE #sFlag = “0”
UNION ALL
SELECT 2 as Value WHERE #sFlag = “1”
I am testing a condition like this in the where clause of a subquery. But I am getting the error "operator must be followed by any or all" when I execute the SSRS report.
dbase is oracle. And i need to use IN with parameter because the parameter in SSRS report is multivalued. I am using a separate function to generate dates that go in :P_Date.
I need to check if this date is = or < or null . All three conditions need to be tested.
where
trunc(tt.fyh_fecha) IN (:P_Date) OR
trunc(tt.fyh_fecha) <(:P_Date) OR
trunc(tt.fyh_fecha) IS NULL AND
tc.cod_tree = 'blue' AND
tt.color_flower = 'pink'
This doesnt seem directly possible - you are trying to use a parameter containing an array of values against the < operator which only expects one value. Your design doesnt make any logical sense to me either (<= multiple dates?), but anyway ...
I would add a join to a Calendar / Date Dimension table, where I would apply the IN (:P_Date) criteria to get a list of Date values as a deliberate cross join.
Then I would replace:
trunc(tt.fyh_fecha) IN (:P_Date) OR
trunc(tt.fyh_fecha) <(:P_Date) OR
with:
trunc(tt.fyh_fecha) <= Dim_Date.Date_Value
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.