I'm designing a report on Ireport with a SQL query, and I'm working with filters, basically I want to be able to compare a input parameter "shift" with a field in my report, so I can show my report by shift.
This part of the report works fine, I just used a filtering expression $F{Shift}.equals( $P{shift} ), however this only works with one shift, but I want to also be able to see all shifts in the same report. Is there a way to do this?
As #Pu297 suggested, I could use an IN comparation in my SQL query, but setting it like this:
SELECT * FROM foo WHERE shift IN P!{shift}
Where my shift ireport parameter is a String and I type it in the way "1,2,3" to show the first 3 shifts
Your SQl Query
SELECT * FROM foo WHERE shift IN ($P!{shift})
And your input text should be
'1','2','3'
Related
I have a calculate field Total Pts which is the sum of the values of report items
=ReportItems!Textbox28.Value + ReportItems!Textbox30.Value + ReportItems!Textbox32.Value
Now I want to put a interactive sort here and I am not able to do so . Any ideas? I can't do it in a query because the reportitems that I am adding are from a two different datasets which are of diff. types eg: sql server & sharepoint
There should be no issue with doing this because SSRS allows you to use an expression to determine the sort order. Just right click on your header textbox for the column and go to the interactive sort tab. Here you can turn interactive sort on, then in the sort by field click the function icon next to the drop down. Use the same expression that you used for your calculated field, and it will sort according to the results of this expression. If there is some reason you can't do this that I'm missing, let me know and I'll try to help.
I'd like to only display certain rows on my report using SSRS if the field value of EMID=3 or EMID=Null. Or if it would be easier, to hide rows where EMID in (1,2)
I right + clicked the row -> Row Visibility -> Show or Hide Based on an Expression and created this expression:
=IIF(Fields!EMID.Value=1 Or Fields!EMID.Value=2,True,False)
But that does not hide the rows I am looking to hide. Any suggestions on what I did wrong?
Thanks,
Most of the times issue with the SSRS value matching expressions are the data types of the values that creates the problems or undesired result.
In your case your EMID field might be coming as the string so you need to make sure that it is convert back to the Int before matching. For that matter always right your expressions in SSRS using type conversion so your expression can be on safer side.
=IIF(CInt(Fields!EMID.Value)=1 Or CInt(Fields!EMID.Value)= 2,True,False)
I am developing a report in Crystal Reports 2011 that has 3 sub-reports pulling data from 3 different databases. I have a Multi-Value Parameter (String) in the main report that passes the input values to the 3 sub-reports which have the same Multi-Value String Parameter.
Sample Input Values are:
P000000030,
P000000930,
P000001730
The user does not want to input the leading alpha character and preceeding zeroes. They want to input the following:
30,
930,
1730
The sub-report pulls all of the records successfully if the user puts the entire string value in with the following Record Selection Criteria, but it does not work with the partial strings input:
{Command.Puchase Order} in {?Pm-?Reference}
Can anyone advise the syntax needed to pull the data in the subreport with the substrings as inputs?
Thanks in advance!
Thank you for your input guys!! I took a bit from everyone and came up with the following solution:
Create a column in the datasource that trimmed out the desired value --> ltrim(regexp_replace(a."po_num",'P',''),'0') as "Puchase Order2"
Modified my Record Selection Criteria to select for either column --> {Command.Puchase Order} in {?Pm-?Reference} or {Command.Puchase Order2} in {?Pm-?Reference}
I really appreciate your input! I am able to deliver the desired solution with your aid.
go ahead and create a formula that calculate the length of your parameter(len({?Pm-?Reference})) and place it suppressed on your report header. Then put below in your record selection formula
right({Command.Puchase Order},{your length formula}) in [{?Pm-?Reference}]
You could add the "number only" version of [Puchase Order] to your datasource...
cast(cast(right([Puchase Order], len([Puchase Order]) - 1) as int) as varchar(9))
as [Puchase Order Number]
...then use that in the select expert. I'm getting the number without the leading P, casting to int to remove the leading zeros, and then back to a varchar for the string comparison in Crystal.
You could do the same with a formula in Crystal reports. Then reference that formula in the select expert. Downside is having to repeat that in all 3 sub reports.
I have a report with multiple data-sets. Different fields from different data-sets are used in different locations of the report.
In one part of the report, I need to do a calculation using fields from two different data-sets. Is this possible within an expression?
Can I somehow reference the data-set the field is in, in the expression?
For example, I'd like to do something like this:
=Fields.Dataset1.Field / Fields.Dataset2.Field
You can achieve that by specifying the scope of you fields like this:
=First(Fields!fieldName_A.Value, "Dataset1") / First(Fields!fieldName_B.Value, "Dataset2")
Assuming A is 10 and B is 2 and they are of type numeric then you will have the result of 5 when the report renders.
When you are in the expression builder you can choose the Category: Datasets, your desired dataset highlighted under Item: and then double click the desired field under Value: and it will appear in your expression string with the scope added.
Using same logic you can concatenate two fields like so:
=First(Fields!fieldName_A.Value, "Dataset1") & “ “ & First(Fields!fieldName_B.Value, "Dataset2")
As PerPlexSystem writes, asuming you only want to compare the first value from a dataset with values from another dataset, you can use the First function.
However, if you want to compare the values of each row from one dataset with with the values from each row of another dataset, then you will need to use a subreport - see here for further details.
Another option is to use a parameter as a variable. This is helpful if you want to create a calculated field in one of the datasets. This is best applied when the parameter value comes from a dataset with a single record.
I've the following WHERE CLAUSE of a SQL Query String in the SSRS Dataset:
WHERE "Input_date" >={ts '2009-01-01'}
AND "Input_date" < {ts '2009-12-31'}
And now, I'd like to use report parameter to wrap up the dates in the SQL statement, i.e.
#indate1, and #indate2.
I've tried this, but error occurs:
WHERE "Input_date" >={ts #indate1}
AND "Input_date" < {ts #indate2}
Please kindly advise.
Thanks.
What have you done to add these parameters? I assume that you have altered the dataset query with the changes you have posted in your question. There are two more steps you need to perform to make this work:
Define a new parameter to the parameters folder. Right click the parameters folder and choose Add parameter. Specify which values you want the user to be able to select. Repeat for the second parameter.
Add the parameters to the dataset you are using for the report. This can be done in the parameters section when you edit the dataset. Add two parameters with the names #indate1 and #indate2, and set each parameters value to the parameters you defined in step one.
Alter the SQL statement as you described in your post. I would think that your SQL should look something like this (assuming Input_date is a column in your table):
WHERE Input_date >= #indate1 AND Input_date < #indate2
This is specific to the BIDS 2008 version of Visual Studio. If you are using report builder or something else, please let me know, and I can change the instructions a bit.