SSRS 2008 R2 chained parameters - reporting-services

I have a report with three parameters: A country combo box, a start date and end date (of the fiscal year). I want the start date and end date to be updated depending of the country combo box selection.
I made a dataset that receives the country code as a parameter and returns the start date and end date for the selected country. Then I linked the default value of the dates to the dataset.
This works perfectly the first time a country is selected but not for the subsequent country selections. If I change the type of the dates parameters to combo boxes it works every time but I don't want to lose the flexibility of "fine tuning" the dates after the country is selected.
am I asking the impossible?

Microsoft regard this behaviour as being by design - see this Microsoft Connect issue.
There is a workaround in general - the dependent parameter gets refreshed when its values are invalidated by the selection in the first parameter.
However, since you want the users to be able to override the start and end dates, you can't specify that the default values for the country are to be the only values available.
What you could do would be to add a second country parameter after the first, whose default and only available values are the value of the first country parameter, and to set the default values of the start and end parameters based on the value of the second country parameter.
Unfortunately, if you set the second country parameter to be hidden, its default value does not get populated - so the second country parameter would have to remain visible, for this to work.
You could make use of this - for example, by displaying the default date range for the country as the label for the parameter; this would enable the user to see where the default date range has been overridden.

Related

SSRS Cascading Params without a dataset

I've done many a cascading param in SSRS but ALL have used datasets, passing in a param value into a query, this time I want to know if a date selection can be done using only expressions.
Periodtype parameter has a value list of 'Day' Or 'Quarter' (those are the labels, the values are "D" and "Q").
I've set the default values of the start and end dates via SSRS expression if periodtype value is "D" then set start and end date to be beginning and end of previous day and if "Q" then similar with previous quarter.
This works when you start up the report, changing the default period type (D or Q).
It won't allow the date to be calculated dynamically when changing the periodtype, can it be done without queries, using just params and expressions, thank-you?
If I've understood your question correctly, I think the issue is not so much to do with datasets, but a long standing issue with SSRS not refreshing parameters, or at least the defaults, even if you specify to always refresh it.
Typically you can force the update by changes the available values.
As an example ...
I set up 2 parameters, the first called PeriodType is a simple text parameter with two available values "Q" and "D", it also has a default value of "D"
The second parameter called StartDate is a Date/Time type.
The following three properties were all set to the exact same expression
Available Values: Specify Values - Label and Value properties
Default Values: Specify Values - Value property
Here is the expression which simply shows todays date if "D" is chosen or the 1st Jan if Q is chosen purely for illustration.
=IIF(Parameters!PeriodType.Value = "D", today(), CDATE("2022-01-01"))
I also set the advanced properties "Always Refresh" option.

Calling a detail report using the intersection of Row and Column Sum as parameters

Description:
I have a report that that aggregates ATM transactions. This report has a Tablix with the following attributes:
Rows;
Vendor, Terminal.
Columns; Month, Day (Date), Hour.
The Row groups Terminal as child of Vendor and the Column groups Hour as child of Date and Date as child of Month. The Row Group and Column Group properties specify that each child visibility is toggled by its parent and the default if each child visibility to be hidden.
The Placeholder Value property for the intersection is set to Sum() transactions. The Action is set to Go To Report and specifies a detail report that accepts;
Start Date,
End Date,
Vendor,
Terminal
As parameters to the detail report. Each time the link is clicked, it calls the detail report with the dataset parameters set at runtime. So, for “North”, the detail report would reveal 41765 rows associated with the vendor “North”.
Problem:
No matter what resolution of detail in the matrix, when clicking the Sum() value to invoke the detail report, the dataset parameters set at runtime are sent to the detail report. For instance, if I drill down from Month to Date, I see that for Vendor “West” the sum of transactions on 2018-07-01 are 81. If I click that link to summon the detail report, it returns the total rows for the Start Date and End Date (1577 rows), rather than for the Date (81) as expected. This behavior is replicated throughout the intersection combinations.
Request:
How do I call up the detail report such that it returns only those rows specified at the resolution of the intersection in its current state? Ie: the sum at Month\Date: Vendor or the sum at Month: Vendor\Terminal or the sum at Month\Date\Hour: Vendor\Terminal….
What is the best method to accomplish the request? My research has not come up with any valid suggestions. I've attempted to use InScope() in the Placeholder Properties expression but can't seem to get it right.
Thanks for your help!
Your thought is correct, you have to use Inscope
Step 1:
For each parameter you use in your main report to call the subreport use an expression like
= Iif( Inscope("matrix1_Terminal"), Fields!Terminal.Value, Nothing)
For numeric parameters (like month number) set a dummy value like -1 because NULL values are not allowed
= Iif( Inscope("matrix1_Month"), Fields!Month.Value, -1)
Step2:
In the subreport change your parameters to accept NULL values (only for strings and dates)
Step3:
On the subreport adjust your query code to handle dummy parameter values
For string or dates
WHERE (terminal = #Terminal or #Terminal IS NULL)
For numeric values
WHERE (month = #Month or #Month=-1)
Important!!
Don't forget to pass to the subreport other parameters needed like filters in the WHERE of the original report
Tip: In the subreport use temporary string parameters for debugging and pass the values of your Inscope expressions

Populate a parameter dropdown based off another parameter

I am trying to populate a dropdown based off another dropdown parameter. I have 5 parameters, but the first 3 populate the 4th in the report. So the 4th and 5th parameter are what the user uses to populate a report. So the 4th parameter (meetings) has a meetings dataset and the 5th parameter is meetingType with a dataset of meetingType. So when the user selects a meeting, then the meetingType gets populated by that selection. Currently both dropdowns produce all results, which I don't want. I just want all results for meetings and then the meetingType gets populated by meeting.
The table it produces once the report is ran doesn't use those properties and there isn't a place to query anything. I can only use available values from each dataset and not use available values based on the selection of the 4th parameter.
I'm not really clear. do you need a parameter or do you just want to have the meeting type available as a value in your report output?
Fairly straightforward. You have two datasets, one for each parameter. You need to filter the second dataset based on the first parameter.
For example, I often create reports that ask for a range of values, let's say programs. Once the user has entered the beginning value, the ending value must be greater than or equal to the beginning value. So, on the ending value dataset I create a filter. In this case, the filter says that the field code (which is my program) must be between the starting parameter and the maximum value allowed:
You can make your filter as complex as needed - referring to the other parameter with a formula
You can also do this via separate datasets for each parameter.
Lets say you have two parameters #param1 and #param2
you want the values on #param2 to change based on #param1 selection.
You will have your main dataset (main_dataset) with a where clause something like this
where sometable.somecolumn = #param1
and sometable.someothercolumn = #param2
Now you create a dataset (param1_dataset) for #param1 which brings back all the values you require for this parameter
Now create another dataset (param2_dataset) form #param2 and add a where clause to it which restricts the returned list.. something like this..
where sometable.somecolumn = #param1
Now on your report parameters.. set the Available Values for each parameter (report parameter properties) to "Get Values from a query" and select the appropriate dataset and the value field and label field (returned by the dataset) for each parameter.
Now when you run your report, your parameter selection 2 should change based on what you selected for parameter selection 1

SSRS report parameter : parameter's value change upon other parameter's value selected event

Here's my scenario,
I have a report in which it has two subreports in it.
each subreports visibility depends on a parameter(A) value.
each event for selecting the parameter(A) value from all available value will refresh other two parameter's(B,C) list of available value with same set of data but different than before the refresh event.
B and C will use one value from the list as its default value.
default value is controlled by expression in default properties of B,C
when A is changed again, cycle repeat.
A, B and C are used to specify date range for query.
A is selection to choose from two options ('WEEKLY','MONTHLY'). The default is 'WEEKLY'.
'WEEKLY' will return list of work week in current year to B and C. subreport1 displayed. subreport2 hidden.
'MONTHLY' will return list of month in current year to B and C. subreport1 hidden. subreport2 displayed.
and expression for default value of B and C is =IIF(Parameters!A.Value = "WEEKLY",datepart("WW",today()),IIF(Parameters!A.Value = "MONTHLY",datepart("M",today()),0))
Now when it loads, A is 'WEEKLY', B and C have correct default value datepart("WW",today()). Then...
I change A to 'MONTHLY', B and C got monthly data right and have right default value.datepart("M",today())
I then change back to 'WEEKLY' B and C got correct weekly data but still retain the default value from the first switch (which is datepart("M",today()) rather than supposed value datepart("WW",today()))
How do I get B and C to get the correct default value per category selected from A?
EDIT:
all subreport have same set of parameter as main report.
im using query to get the list for B and C.
so far query is working fine producing the list.
query is a procedure which take in parameter A then returning recordset of whether work week or month in current year.
every subreport have same parameter definition as in main report.
i actually doesn't know much how to use subreport. try and error here.
so when ssrs prompt me about some parameter definition is not defined for some subreport i matched parameter in subreport to parameter in main, at parameter tab of subreport properties.that's the only error i got through when building this report.
So after a bit of faffing I have managed to reproduce and the behaviour you require from our parameters. Apologies if this goes over ground you have already completed, or doesn’t work, but it behaves as expected for my configuration (SSRS 2008 R2).
Parameter A is set up with available values of “WEEKLY” or ”MONTHLY” for both the Label and Value, with a default Value of “WEEKLY”.
Parameter B is then set up with the available values’ for Label, Value and the Default values’ Value all set to your expression
=IIF(Parameters!A.Value =
"WEEKLY",datepart("WW",today()),IIF(Parameters!A.Value =
"MONTHLY",datepart("M",today()),0))
Available Values
Default Values
This is all repeated for parameter C
Now when I first run the report I am faced with the following
When I choose Monthly I get
Then when I choose weekly again I get
Only when I choose monthly and select "View Report" does the visibility change on the report
I'm not certain you filled out all these steps when you asked the question - you may have done - but it is worth giving the above a go from fresh and see if the behaviour is as you require
Any problems, let me know, and I'll try to help further

SSRS Date Parameters - Setting Date B = Date A whenever Date A is changed

I am looking into a query from one of our users regarding the behaviour of date pickers on their report.
They have asked that when they enter a date in Date Paramater A that this is then duplicated in Date Parameter B.
I can achieve this when the report is first run by given Date Parameter A no default value (so it has to be chosen by the user) and seet Date Parameter B's default value via an expression to "=Parameters!StartDate.Value".
The question though is wether or not I can recreate this when Parameter A is updated. Therefore if they run the report once and then decide they need to choose another date. Can I set Date Parameter B to refresh each time Date Parameter A is changed?
E.G
Report is opened
Date Parameter A is set to 02/12/2013.
Date Parameter B now defaults to 02/12/2013.
Search is performed
A second search is required so, without closing the report the user changes the date in Date Parameter A
Date Parameter A is now set to 05/12/2013
Date Paramater B still says 02/12/2013 - can I somehow make this auto refresh to match Date Parameter A if Date Parameter A changes?
EDIT: Thanks to Kalim for pointing this out but it must also be noted that although I would like Date Parameter B to default to the new value selected by Date Parameter A, dates greater than that selected for Date Parameter A must also be available in case they wish to widen the range of dates.
Hopefully that is clear, but if any further information is required then please let me know.
Thanks in advance for your time and help.
You should be able to set the "Available Values" to the value of the first date parameter.
Select "Available Values" then select the "Specify values" option. Add a value and edit the expression of the value. Set this to the same expression you used in your default value expression.
Hope that makes sense!
Screenshot: