Mutually dependent parameters - reporting-services

Is it possible to change ONE parameter drop down values if ANOTHER parameter drop down values has been changed?
For example, you have two parameters:
drop down YEAR (simply populated int values from stored procedure: 2016,2017,2018)
drop down TYPES (product text value list from stored procedure)
Can we select YEAR 2018 and it will show specific values in TYPES.. then select any other year and show DEFAULT values? Both parameters are calling stored procedures.
IN SHORT:
Idea is to select the year and only show in TYPE parameter related to that YEAR product TYPE.

You can do this but there are a few caveats.
Datepickers don't work well but if you only select a year 9as a number) then this should be fine.
Default selected values may not be set to what you expect if you select a year more than once (i.e. you choose 2018 then change your mind and choose 2017).
Basically you just need to make the seconds dataset, rely on the value of your first parameter. I don't know what you data looks like but let's assume that you have a large dataset and each record has a Year, Type and then some more detailed columns.
Assume you want to choose the year, then choose from s list of types that are present in that year. I won't cover the final dataset as it's not part of your question ..
So let's say the first stored proc does something like
CREATE PROC GetYears AS
SELECT DISTINCT [year] FROM myTable ORDER BY [Year]`
Create a dataset called dsYears and point it to this stored proc.
In SSRS you create a parameter called say #pYear and set the available values to point to dsYears
Now create your second stored proc that accepts a year as a parameter so the proc will look something like
CREATE PROC GetTypes(#pYear as int) AS
SELECT DISTINCT [Type] FROM myTable WHERE [Year] = #pYear
Create a seconds dataset called dsTypes and point it to the seconds stored proc setting the parameters to be you #pYears parameter.
Now create your second parameter called #pTypes, make is multi-valued (I assume you want to select more than one type at a time in your final report). Set the available AND default values to point to dsTypes
That should be it. I've done this from memory so it might not be perfectly correct but hopefully close enough.

Related

How to get procedure result in another procedure without OUT parameter

I have made a procedure which returns multiple values and i want to use these values in another procedures without OUT parameter. is there any solution?
Depending on the actual type of result you want to "transfer" from one procedure to the next there are different options:
If your fist procedure produces only a small number of individual values (like a single id or a count or sum of something) you can store them in (a) variable(s) and use them for calling the next procedure. Otherwise - for data in a tabular form - you can create a temporary table which you then access from your second procedure.

Display selected values of multi-value parameter in tablix rows

I am designing a report for SSRS. I want the user requesting the report to be able to specify, when they generate the report, from a pre-defined selection some values which should be displayed in a tablix on the report.
I have therefore created a multi-value parameter and populated the Available Values with the options I want the user to be able to select from, and, as expected, when the report is generated the user is able to select one or more of these values.
However, what I now want to do is include a tablix in the report, and display a row for every value in the multi-value parameter that the user selected, with the value displayed in the first cell of the row.
If the values were coming from a data table this would obviously be easy. I've also found answers on how to show all of the selected parameter values in a single textbox using the JOIN function, but I don't want to do that.
The only solution I can think of is to replicate the list of available values in the multi-value parameter in a tablix manually, and link the visibility of each row of the tablix to the selected state of the corresponding value in the multi-value parameter, but that's not very elegant and increases the effort involved in maintaining the report definition.
Any ideas on how to do this? I know the selected values from the parameter simply form an array, but I can't see how to bind a tablix to any data that isn't in a dataset, or how to create a dataset from the parameter values.
Considering that a tablix sources from a dataset, I did some experiments to see how to create a low maintenance solution for you.
Option 1: Create a data set with hard-coded options to match your multi-value parameter and select those options WHERE they exist in the parameter.
Example:
SELECT val
FROM (
SELECT 'opt1' as val
UNION SELECT 'opt2'
UNION SELECT 'opt3'
UNION SELECT 'opt4') a
WHERE val IN (#Param)
Thoughts: easier to maintain than visibility on a table, but still two hard-coded places within the report.
Option 2: Create a dataset that selects the multi-value parameter and splits it by each value. This was my first idea, but I ran into some issues with determining how to actually select the multi-value without a syntax error. I came up with a method that creates a deliminated string in the report and than parsed that string back into rows in the dataset:
Step 1) Within the dataset properties, on the parameter tab, join the multiple values together with a JOIN expression
Step 2) Create a simple query which uses the new SQL Server 2016 function string_split. Note that your database compatibility level MUST be 130 or higher to use this function (SQL 2016+). If this isn't your scenario, there are many string split functions that you can find on Stack Overflow to achieve the same thing.
Fun problem!

Multiple Terminal to select a number from a list

I am using c# winforms-MySql Server.
I have 12 values and in every hour I need to select one value from that 12 value list. Timer can easily select the number.
But the problem is I have 5 Terminal where the software is to be installed.
They all will select a value from the list. The value can be same or different.
But I need the select same value for all the terminal. I don't have any client-server facility because any terminal can be open or closed at any time.
Can MySql select a value from a list in every hour without any c# code?
Any concept will be helpful. I don't need any code if you have a problem.
Thanks
A solution can be:
Create a Table with only 1 Column and 1 Row. It will contain, in the single cell, the current synchronized value;
Create a Timer in mySql. You can get some useful infos here;
The Timer makes a Stored Procedure to run;
That Stored Procedure updates the synchronized value;
All the Terminals query the database looking for that value, whenever and however you want: they will always retrieve the a synchronized value.

How can i run the report without specifying the parameter value in SSRS

H, I have a parameter 'Client' as drop down in SSRS report. My requirement is to select all the records for all the clients if i don't select any parameter value and if i select particular value in the drop down,i need to display records for the that particular client.
I am getting the list of clients as a input from query.How can i add option select all by default.
Thanks in advance
You can do this a few ways...
Check the "Allow Multiple values" on the general tab of the Parameter Properties, go into the Available values and select the dataset you are using to get the values, make sure the the column that contains the actual data to search on is what you select for the VALUE field...(with this one - make sure your query eliminates the NULLs for the Value field) then you will have a drop down with all the values and it will add Select All...
Then in the Default Values tab, you can hook to the same query and select the VALUE field again... (as long as there aren't any NULLS) You may need to do tweaking depending on your query and values...
or
You can check the "Allow Null Value" on the General tab in the Parameter Properties, then in the Default Values - select "Specify Values", then Add, and (null) pops in there automatically...
Then call a stored procedure where the parameter defaults to NULL and if you pass NULL or don't pass in a string of values, your query will return all (not sure how you'd implement this if your query is embedded in the report... I try to do all of mine in Stored Procedures..)
Add "All" to the results of the query that returns a list of clients for the drop-down and make it the default selection. Then handle it in your main stored procedure that if "All" was selected, you don't filter by clientId, and just get all clients.

Working with parameters in SSRS 2008

I have an (either or) situation in regards to parameters in SSRS 2008. I currently have my report working with a date range but I've been asked to add a drop down for the user to select the weekending date. I've got that drop down working but how can I switch between parameters (Date Range and the use of the Weekending Date drop down) for sending parameters to my report?
The way I allways fix this is by setting the parameters as nullable.
Then in my sql script I select all dates on the weekending date or between the daterange:
So whatever the user specifies, your sql script is filtered based on their parameters.
select *
from [table] t
where t.[date] = #WeekendingDate
or t.[date] is between #DateRangeFrom and #DateRangeTo
I usually handle this situation by creating an Internal Parameter(s) to sit between the UI and the query or stored procedure. The Internal Parameters are driven by expression depending on the user selection.
so lets say you want the user to either select a begin and end date range(Begin: 2012-01-01 End: 2012-01-31), or a month (Jan 2012).
If they select a value for Month. I convert that to an equivalent date range in the internal parameter expression. If they enter a date range I just pass through the begin and end values to the internal parameters.
Hopefully this makes sense. with a little work and imagination I think the approach can handle most scenarios.
One possibility would be to use the version control system of your choice to make another branch for the second report, change that one to use Week Ending, and then just make sure you merge changes every time you make a change to the main report.
I'm sure someone will come up with a cleaner way to handle it, though...