SSRS parameter issue for checking multiple condition - reporting-services

I am passing a date parameter and in SSRS Dataset Filters I am filtering the tasks whose created date is below the parameter passed date
=cdate(Fields!WI_CreatedDate.Value)
>=
= (Parameters!SinceDate.Value)
If I want to check the condition for task Closed date & tasked resolved date, then How can I mention it in the parameter or there is any other way around ?
Condition should be like
Sincedate <= (CreatedDate or Closed date or Resolved date)

You should be able to handle this by using an IIf expression to perform the check and return a pass/fail condition, something like:
=IIf(Parameters!Sincedate.Value <= Fields!CreatedDate.Value
or Parameters!Sincedate.Value <= Fields!ClosedDate.Value
or Parameters!Sincedate.Value <= Fields!ResolvedDate.Value
, true
, false)
Set this as a boolean filter to show when the expression = true.
This way it will display rows that fulfil at least one of the checked.

Related

SSRS Expression to Sum value IIF YearMonth = Parameter

I hope someone would be able to assist\help.
I have a Tablix that I'm trying to populate with three separate (summed) values (Current Month, Current Year and Previous Year) from one field based on a parameter. My parameter is set as yyyymm. My expression logic is as follows for each summed value:
Sum Current Month values
=SUM(Fields!Quantity.Value),IIF(Parameters!YearMonth.Value) = CDATE(Now()), "yyyyMM")
Sum Current Year values
=SUM(Fields!Quantity.Value),IIF(Parameters!YearMonth.Value) = CDATE(Now()), "yyyy")
Sum Previous Year values
=SUM(Fields!Quantity.Value),IIF(Parameters!YearMonth.Value) = CDATE(Now()), "yyyy")-1
I'm getting the following error when attempting the above expressions:
The Value expression for the textrun Quantity5.Paragraphs[0].TextRuns[0] contains an error: [BC30205] End of statement expected
As Harry pointed out, the IIF statement syntax is
IIF([Expression to evalute], [Expression to return if true], [Expression to return if false])
Also, I think you need to format the date you get back from now() so it matches the format of your parameter.
So, taking your first expression it should be something like
=SUM(
IIF(Parameters!YearMonth.Value = FORMAT(Now(), "yyyyMM"), Fields!Quantity.Value, Nothing)
)
So starting at the inner expression, we compare the parameter to today's date formatted as yyyyMM. If the match the return the value of the Quantity field, if not return nothing.
The outer SUM then just sums all these results.

Error when runing query from form between two date from a form

I have a form called FirstInLastOut which looks as the image below.
Based on Name or badge number I want to search between two dates.
I am using the following criteria on the query:
>=[Forms]![FirstInLastOut]![StartDateEntry] And <=[Forms]![FirstInLastOut]![EndDateEntry]
This is given me results that include other months as well. Please see the query report below.
So as you can see in the image the numbers of the dates are falling with the the parameter but getting other months as well.
How can I make it so it will only select the dates between the date ranges?
SELECT FistClockInRaw.Badgenumber, FistClockInRaw.name, FistClockInRaw.lastname, FistClockInRaw.MinOfCHECKTIME, FLastClockOutRaw.MaxOfCHECKTIME, [MaxOfCHECKTIME]-[MinOfCHECKTIME] AS TotalHours, FLastClockOutRaw.QDate, FistClockInRaw.MinOfQTime, FLastClockOutRaw.MaxOfQTime, RawCompleteQuery.CHECKTIME
FROM RawCompleteQuery, FLastClockOutRaw INNER JOIN FistClockInRaw ON (FLastClockOutRaw.Badgenumber = FistClockInRaw.Badgenumber) AND (FLastClockOutRaw.name = FistClockInRaw.name) AND (FLastClockOutRaw.QDate = FistClockInRaw.QDate)
WHERE (((FistClockInRaw.name)=[Forms]![FirstInLastOut]![FirstNameEntry]) AND ((RawCompleteQuery.CHECKTIME)>=[Forms]![FirstInLastOut]![StartDateEntry] And (RawCompleteQuery.CHECKTIME)<=[Forms]![FirstInLastOut]![EndDateEntry]));
is the Query
I assume that the forms fields StartDateEntry and EndDateEntry are bound to fields of type date.
I also assume that you are only interested to compare the date part of those form fields.
So try this condition instead to assure correct date interpreting:
WHERE FistClockInRaw.name=[Forms]![FirstInLastOut]![FirstNameEntry]
AND RawCompleteQuery.CHECKTIME >= Format([Forms]![FirstInLastOut]![StartDateEntry], "\#yyyy-mm-dd\#")
AND RawCompleteQuery.CHECKTIME <= Format([Forms]![FirstInLastOut]![EndDateEntry], "\#yyyy-mm-dd\#")
A remark:
Be aware that every date field/variable always contains a time part too!
So your current logic comparing EndDateEntry with <= can cause trouble, because you would only get results of the end date having time values of 00:00:00 in the field CHECKTIME.
If any record of CHECKTIME contains the requested end date and a time part bigger then 00:00:00, it is not in the result.
To avoid that, you should use < and add one day:
And RawCompleteQuery.CHECKTIME < Format([Forms]![FirstInLastOut]![EndDateEntry] + 1, "\#yyyy-mm-dd\#")

SSRS parameter to select "future" or "past" dates. (contracts expired or current by expiration date)

What expression and dataset query structure would I use to add a drop-down filter to filter contract records by date, selecting either "Expired", ExpirationDate < Today(), Or "Current", ExpirationDate >= Today()?
One option is to use a parameter along with a dataset filter.
Add a new parameter to the report.
Set the Available Values to "Expired" and "Current".
Add a Filter to your DataSet with the expression to check each row. For example:
=IIf(Parameters!MyParam.Value = "Expired" And Fields!ExpirationDate.Value < Today, true, IIf(Parameters!MyParam.Value = "Current" And Fields!ExpirationDate.Value >= Today, true, false))
The Filter should look like this:

SSRS 2008 parameter dates and nulls

I have a report of customers that I wish to run in SSRS. The report I want to return is for a particular period (e.g. 01/01/2016 and 29/02/2016). The parameter is against a date field (End_Date).
What I would like to return is a list of customers WHERE End_Date is either BETWEEN the dates above (or any other period) and WHERE End_Date IS NULL too.
I am able to create a parameter that will list customers with an End_Date between the dates I want but how do I also get the parameter to also list the NULL values.
Hopefully that's clear but just in case - I need a list of customers where End_Date is between two dates or NULL.
Thank you
You need to account for the possibility of a null in your evaluation using an OR for the END_DATE.
Are you using the parameter in the query or on the dataset? The SQL is a bit different that the SSRS expression.
SQL
WHERE DATE_FIELD >= #START_DATE AND (DATE_FIELD <= #END_DATE OR #END_DATE IS NULL)
SSRS
=IIF(Fields!DATE_FIELD.Value >= Parameters!START_DATE.Value AND (Fields!DATE_FIELD.Value <= Parameters!END_DATE.Value OR ISNOTHING(Parameters!END_DATE.Value), 1, 0)
In the other filter properties, set the type to Integer, Operator to =, and Value to 1.
This will evaluate the expression and return 1 if it matches and 0 if not - then it filters for the 1.

To fetch based on filter by expression component in ETL

I have filter condition based on date. where it needs fetch records between given dates.
in filter by expression I gave as below
the field is date datetype and format is YYYYMMDD
fieldname >= '20020502' and fieldname <= '20050430'
but records are not passed next component.
Did I gave the condition righty?
I have another method which always works....
Use date_diff function for the same....
Condition will be provided as below :
Date_diff(date1,fieldname).days >0 & & date_diff(date2,fieldname).days<0
Try typecasting the dates.
(date("YYYYMMDD"))fieldname => '20020502' and (date("YYYYMMDD"))fieldname <= '20050430'
The first point you need to check here is what is the data type of the field.
If the field is a date or datetime type then use directly the functions like date_diff() or so.
If the field is of type string or decimal then a typecasting to date or datetime is necessary before you use the functions like date_diff().
Thanks
Arijit
As you mentioned that
field is already in date datatype with YYYYMMDD format
You only have to typecast the right-hand-side of your expression.
my_date >= (date("YYYYMMDD")) "20150102" && my_date <= (date("YYYYMMDD")) "20150105"
Considered input data and output is:
20150101
20150102 --> with the above condition goes to output
20150103 --> with the above condition goes to output
20150104 --> with the above condition goes to output
20150105 --> with the above condition goes to output
20150106