I work with CRM 2015.
When I try create report with multiply-values parameter, I can not split it on list id.
I tried many ways to do it like:
ALTER PROCEDURE [dbo].[pn_rep_LoadResources]
(#Stage NVARCHAR(1000))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.FnSplit(#Stage,',')))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.Split(#Stage,',')))
WHERE(stage.new_stageid IN (SELECT Value FROM dbo.Split(#Stage,',')))
WHERE(stage.fn_GetGuidsFromString IN (SELECT Value FROM dbo.Split(#Stage)))
And other, but nothing works.
Have anyone problem like this?
Related
I've used the join function to create a string out of an array of variables.
=Join(Parameters!Variable.Value, ",")
Let's say that the expression is using a parameter called Variable to an expression called varstring. As well as to verify that it's working correctly, I created a text box in my report to show me the output of varstring. It looks like this:
123,456,789
Now I'm passing that string as a variable to a stored procedure. The code in the stored procedure would look similar too:
Declare
#var varchar(30) = varstring;
Select * from table where value in (SELECT * FROM string_split(#var, ','))
Lastly, the Variable parameter in SSRS is set to allow multi-values.
When I run this though, my report only returns records associated to the last string split. So in the above it only returns records equal to 789 in the report.
When I hardcode the values into the stored procedure, it returns records where value equals 123,456, and 789.
What am I missing?
I have certain parameters in the crystal reports which would be passed directly into Stored procedure in sql . Parameter A has 5 values and I want to enable them for users so that when user opens up the report , he is able to select any number of parameters values in the drop down based on which report data would be filtered.
Please advise
For a parameter to select multiple values you need to enable the option allow multiple values to true.
As I know, in designing a report in Crystal Reports you can use a simple SELECT like this:
SELECT CAST(0 AS int) AS Id, CAST(0 AS varchar(0)) As Name
That will give you two fields like Id, Name and you can use them in your report.
Now, you can use that type of SELECT statement instead of running a stored procedure like EXEC SP1 #P1 = P1, #P2 = P2 just inside of your report designer and running that stored procedure when you are filling the Data-Set of your report.
I have a report that I am working on that will do the following:
Return results based first on the community selected by the user.
Filter to find alike addresses within the community, based on the number of square feet at each address.
Set the end date (a column within the data table) to a user defined parameter for use in a WHERE at the end of the query.
The relevant information is stored in the following places:
Community: ub_subdivision.descr
Address: ub_serv_loc_addr.location_addr
SqFt: arp_ops.dbo.vw_ub_serv_loc_classifications.SqFt
I have setup the query with 3 parameters:
#Community
#Months
#Address
When the user is running the report, the following should happen (in this order):
The community parameter should populate the values stored in ub_subdivision.descr and allow the user to select the community they want from that list.
The address parameter should populate the values within the selected community from step 1, and allow the user to select the address they want from that list.
Based on the selected address, the query should store the value of the SqFt related to this address and use that in the WHERE statement as follows: WHERE (arp_ops.dbo.vw_ub_serv_loc_classifications.SqFt = #Address)
The months parameter should allow for user input to define how many months of data they want. This parameter is called in the query in the WHERE statement: WHERE (ub_bill_run.def_end_dt > DATEADD(m, -#Months, GETDATE())).
If I save the dataset and create a "table report" in Report Builder 3.0 it does the job of recognizing the various parameters and loading them into the Parameters folder and into the Datasets' parameters.
The problem I have is that I am not able to change the parameter properties to display Available Values and select "get from a query". If I go this route, and try to run the query I get an error that I am using "forward dependencies".
I need the #Address parameter to display the address field as the label, but store the sqft field as the value. This is the way I know how to do this and, unfortunately, it doesn't seem to work.
I would appreciate any insight anyone may have.
Thanks!
John
There is one way to solve this make sure the order should be in the order of
#Community
#Months
#Address
change order to:
#Community
#Address
#Months
just delete existing #month and again add it manually and save it.
i hope it will work for you.
You cannot have parameters based on your main data set.
The forward dependency error is caused because your data set is to be filtered by your parameter, yet it is depending on the same data set to find its' set of values. This is a sort of paradox.
When using queries to define the set of values for your parameters, make sure you create a new data set for each parameter.
Next, make sure the parameters are listed in the order you want them to run. Within the data sets for your parameters, you may use where clauses to make them dependent on one another in the order that they run.
In this example:
Parameter data set for Community:
SELECT DISTINCT ub_subdivision.descr
FROM [YOUR JOINED TABLES]
Parameter data set for addresses:
SELECT DISTINCT ub_serv_loc_addr.location_addr
FROM [YOUR JOINED TABLES]
WHERE ub_subdivision.descr IN (#Community)
Parameter data set for SqFt:
SELECT DISTINCT SqFt
FROM [YOUR JOINED TABLES]
WHERE ub_subdivision.descr IN (#Community)
AND ub_serv_loc_addr.location_addr IN (#Address)
You should also make a month data set for your #month parameter, however it is not dependent on the other parameters so I will leave that to you.
Hope this helps!
I'm fairly new at stored procedures and using them with SSRS.
I want to create a simple SSRS report using a Stored Procedure with a parameter allowing multiple values (results from a separate Procedure)
I have 2 simple stored procedures as Follows.
Create Procedure WO
#STARTDATE datetime, #ENDDATE datetime, #DISTRICT varchar(25)
AS
SELECT A.WO, A.CUST, A.DISTRICT, A.COMPL_DATE
FROM WORK_ORDERS A
WHERE A.COMPL_DATE between (#STARTDATE) and (#ENDDATE)
and A.DISTRICT_NAME in (#DISTRICT)
Create Procedure DISTRICT
AS
SELECT B.DISTRICT_NAME
FROM DISTRICTS B
In my SSRS report, I'm reporting the WO Procedure using the result(s) from the DISTRICT procedure using a "DISTRICT" parameter with the available values from the DISTRICT procedure (ALLOWING MULTIPLE VALUES). Also I've used the DISTRICT Parameter in the Parameters of the WO procedure.
This works when selecting one District, but not when I select multiple districts. Anyone out there willing to help?
If I'm not mistaken, the problem is handling the string parameter #district - presumably, SSRS is passing something that looks like "N,S,E,W", assuming 4 districts were selected - the stored proc would then come out as: ...A.District_Name in ('N,S,E,W')... which would only return a value if there were a district name 'N,S,E,W'. So, I think you need to split the incoming value and reassemble it as 'N','S','E','W'. Unfortunately, there's no SPLIT function in SQL Server, so you either have to write a UDF (there are several posts available) or make a CLR call.
Here's a clever (and untested) thought - try Replace(#District,',',''',''') (I think I got the quotes right...)
Is there anyway to show the user what values are in each field so they can filter on these values?
How is the user supposed to know what values they want to filter if they can't see the values?
If I correctly understand what you are asking:
1) Set up a data set to retrieve the available values for your filter
SELECT DISTINCT MyFieldValue FROM MyTable
2) Create an SSRS parameter which will be used for the user to select a filter. Set it up to allow multiple values, and set the available values to use the data set created in step 1. Let's call this Step2Parameter.
3) Create your core data set for the report, and use the parameter from step 2.
Select MyID, MyFieldValue, Name, Blah FROM MyTable WHERE MyFieldValue in ( #Step2Parameter )
You can repeat this with multiple fields.
Does that get you in the right direction?
Also, make sure that in the Parameter Properties (right click your parameter and select Parameter Properties), that "Select Parameter Visibility" in the "General" menu is set to "Visible".