I am trying to count a field based on the date in another field. s there a way to perform this function in SSRS?
I have tried
=CountDistinct(IIF(IsDate(Fields!EntrySystemDate.Value)=IsDate("d",-1,Today()),1,0) AND ((Fields!DesignCode.Value),1,0)
It looks like your issue is with IsDate, it's a true/false function. You'll need to use DateAdd. I'm not sure how you want to evaluate DesignCode.
=CountDistinct(IIF(FormatDateTime(Fields!EntrySystemDate.Value, DateFormat.ShortDate) = FormatDateTime(DateAdd("d",-1,Today()),1,0), DateFormat.ShortDate) AND ((Fields!DesignCode.Value),1,0)
Related
For Example i have two Parameters of Date
first: 1/21/2016
Second: 4/21/2017
I want to get second date.Is it possible through any SSRS Expression?
Yes. Assuming that the names of the parameters are First and Second, then you can access the values using the following expression.
=Parameters!First.Value
=Parameters!Second.Value
You can use this type of expression for any parameter, of any type, as long as you know the name.
I'm trying to do an IIF expression on a 2nd dataset to sum the 'BookingsComfirmed2016LASTWEEK' column and then divide it by the sum of the 'Stock2016Week' column in the dataset I'm in and where the PropertyTypeCategory = Cottage, but with no joy. I'm sure it's something to do with the placement of the 2nd dataset name, but would appreciate any help. Regards Claire
Dataset1 = TradingLastWeekandYTD
Dataset2 = TradinglastWeekandYTDSTOCK
=(IIF(Fields!PropertyTypeCategory.Value, "TradingLastWeekandYTD" = "Cottage",Sum(Fields!BookingsConfirmed2016LASTWEEK.Value, "TradingLastWeekandYTD")) /(IIF(Fields!PropertyTypeCategory.Value = "Cottage", Sum(Fields!Stock2016Week.Value)),0)
Your iif() won't work like this.
You can't check row by row in a dataset you're not currently working in, which is what you are trying to do with the first part of the iif().
You can use custom code to do an aggregated lookupset() to get the values of the first part.
This link https://itsalocke.com/aggregate-on-a-lookup-in-ssrs/ will help you do the custom code.
For the lookupset(), you would have to do something like..
=Code.SumLookup(lookupset(Fields!PropertyTypeCategory.Value, "Cottage", Fields!BookingsConfirmed2016LASTWEEK.Value))
This assumes that your custom code function is called "SumLookup". It will sum all the values that the lookupset() returns.
I have a query which filters records based on dates (start date and end date)selected in a previous form. I want the query to filter the specific date range, or output all records if the fields are left blank.
I am unfamiliar with SQL. is there a way to add an if-then statement?
I can use vba if necessary, but would like to use the Access GUI if it is possible.
If you have a parameter, used in WHERE clause (Criteria in query builder) and you want to show all records if parameter is empty, just add this parameter as new column and OR condition where indicate Is Null or, better add a column with expression Nz([MyParam],"") and in Condition area inORrow add""`. Unfortunately in query builder this construction may be quite complicated if you have few parameters, in SQL it looks much simpler, for instance in your case it will be something like this:
WHERE (MyDate >= [paramDateStart] and MyDate <= [paramDateEnd])
OR (Nz([paramDateStart],"")="" AND Nz([paramDateEnd],"") = "")
Sometimes simpler edit SQL and then switch to Design view
You can use these criteria for StartDate and EndDate respectively to compare them to themselves in case one (or both) of the search fields on the form is empty (Null):
>=Nz([Forms]![YourForm]![FromDate], [StartDate])
<=Nz([Forms]![YourForm]![ToDate], [EndDate])
I have a master that can be filtered using 4 different parameters. I used a iif statement to join all the parameters to filter the report.
The problem I am now having is when more than one paramater is selected, it tends to return values for the first parameter rather than for all
My paramter expression is as follows:
expression
iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
values
=iif(IsNothing(Parameters!Div.Value)=0,Parameters!Div.Value
,iif(isnothing(Parameters!St.Value)=0,Parameters!St.Value
,iif(isnothing(Parameters!Sp.Value)=0,Parameters!Sp.Value
,Parameters!Hc.Value)))
Any help will be helpful
I think what you are trying to do is something like this:
=IIF(NOT ISNOTHING(Parameters!Div.Value), Parameters!Div.Value,
IIF(NOT ISNOTHING(Parameters!St.Value), Parameters!St.Value,
IIF(NOT ISNOTHING(Parameters!Sp.Value), Parameters!Sp.Value,
Parameters!Hc.Value)))
Do you only want to check for one value?
I usually check each parameter separately so it uses all of them at once. Though there may be a situation where your theory is what you want.
If you want to evaluate all the parameters, just add them to the FILTER of the dataset, table, or group. Choose your field in the Expression and the Parameter in the Value.
I am trying to use parameters within my expression because I won't be able to use the parameters in the dataset, I am trying to do a simple expression but I am struggling to figure out what I am doing wrong, here is what I want to achieve:
I want to count the rows when the Month(Date) = #Month.
What I have so far:
=IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,CountRows(),Nothing)
My results return no values which I am assuming must be something to do with my false return.
You need to use the IIf expression as part of a larger aggregation expression, something like:
=Sum(IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,1,0))
For each row in Scope, this will either add 1 or 0 to the running total of rows that fulfill your check, the end result being the total of rows that match the month.
Depending on where you're adding the expression, you may need to add a Scope parameter to get the correct result, e.g. something like:
=Sum(IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,1,0), "DataSet1")