SQL Server Report Builder - How to grey out a parameter with multiple sub-reports? - sql

I have a main report which has three sub-reports. I am trying to grey out one of the parameter option when a certain report is selected. The reason I want to do that is because one of the sub report does not use this parameter.
Here's the code I am using now. The parameter displaying the query result is #device.
--When user select report 2, the parameter displays the device list from table2.
IF #selectReport = 2
BEGIN
SELECT DISTINCT type
FROM table2
END
--When user select report 3, the parameter displays the device list from table3.
IF #selectReport = 3
BEGIN
SELECT DISTINCT type
FROM table3
END
--When user select report 1. I want to grey out the parameter, but I could not do it.
--So I created the table contains NULL value.
--So, when the user select the report 1, the parameter will show only null value.
IF #selectReport = 1
BEGIN
SELECT DISTINCT type
FROM nullValueTable1
END
I want it to be grey out when the report 1 is selected instead of show NULL on drop down list. Any idea???

You can't grey out the parameter. Unfortunately you can't hide the parameter either as the hidden property only takes True and False. What you are doing now might be the best you can do. However, you could try looking at cascading parameters, maybe you might be able to provide a slightly more user friendly value like "None" to the dropdown.

Related

SSRS Drop Down List Problems

This questions kind of carries on top of the previous question I asked. Anyhow, I am creating this report in Report Builder 3.0. I have about 5 tables, 1 - 5. I have a drop down list that displays the table names 1-5. However, I want to regroup some of the tables together. For instance, the upgraded drop down would look something like this:
Drop Down List:
One&Two
Three&Four
Five
So If i were to click on One&Two, tables 1 and 2 would display while the others would stay hidden.
((CASE WHEN 'All' = 'All' THEN 1
WHEN #Input = 'One&Two' THEN 1
When #Input = 'One&Two' THEN 2
ELSE 0 END) = 1)
Using the above case doesn't do anything.
In my tablix properties I have the following command:
=Parameters!Input.Value <> "One&Two" AND Parameters!Input.Value <> "All"
This doesn't give me the table nor the columns, however doing this for a textbox it works. Going back to my original problem, how can I display 2 tables using only one drop down value from the list and hide the rest. I tried doing the multi select, but that didn't work out so well, because of the visibility issue.
You are referring to the hidden property evidently. Can you check and make sure you should be using label to compare?
=Parameters!Input.Label<> "One&Two" AND Parameters!Input.Label<> "All"

How to assign one same label for multiple value in non-queried available values in ssrs 2005 report?

Parameters - Multiple Values For One Label - Possible?
Sorry my modified Question.....
I have question to ask,...
Is it possible to have multiple values for ONE label in non-queried available values in SSRS 2005? i want to join fields value in a single row like,
Works: (But this bring a long list in drop down menu - which i donot want)
Label Value
---------------------------
Site-1 150
Site-1 151
Site-2 152
Site-2 153
Required result (Which i want - in one line)
Label Value
---------------------------
Site-1 150,151
Site-2 152,153
(which will bring one label and related multi-value in drop down or combo box.
But the problem is that ColumnName IN (#Site) does not work with multi-value.)
More description of the problem:
Let say, I have a field/column
Name = Site
Value = C150,C151, C152, C153
I want drop down menu on report with
C150,C151(as Site-1) & C152,C153(as Site-2)
So I created parameter i.e. #getSite and set values as
multi-value in the report as
Label Value
---------------------------------------------
Site-1 (150,151)
Site-2 (152,153)
And set my parameter as #getSite:= Parameters!#getSite.Value
And Query i wrote as,
SELECT * FROM ..
WHERE Site IN (#getDisease)
But after all these, my report result is empty,literally no result.
It seems like if i select only one value as Site-1 = 150, then it works
but not two or more values in one line,
why it is not possible?? if yes then how?
Please help!!!
Yes just Right Click on your parameter in your Report Data window under Parameters folder and select the check box for allow multiple values as follows
this is what I said before you need to put your column name inside a set of paranthesis something like this
SELECT * FROM ..
WHERE (Site IN (#getDisease))
I have been working on this problem for a while and I think I have finally figured it out...
Basically you need to use a backwards case statement in your SELECT statement, put that in a derived query and then reference it in the outer WHERE clause..
SQL:
SELECT * FROM
(
SELECT
Label
, value
, CASE WHEN [value] IN (150,151) THEN 'site-1' WHEN [value] IN (152,153) THEN 'site-2' END AS [grouped_values]
)
WHERE grouped_values IN (#getSite);
*Note: This answer only works on values that are mutually exclusive, if both sets had the same value included then it would be problematic..
--
Hopefully this can put you in the right direction. I am finding a lot of the reporting services tricks require reverse engineering or at least some reverse thinking.
cheers,
Michael

Showing specific data without filtering out query data

I need to build a form where one field (Unplanned Amount) will only populate with data if another field (status) equals a certain value ("not in workflow"). If the status equals anything else, Unplanned amount field would be blank.
The data is coming from three different tables:
Table 1) AccountNum
Table 2) DocNum, DocAmount, DocStatus
Table 3) CommitAmount
The value in CommitAmount will always equal DocAmount, but the value of DocAmount doesn't have to equal the value of the CommitAmount if it's "unplanned."
I tried putting the data into a query and using the following code on my form to no avail:
If Me.DocStatus = "Not in workflow" Then
Me.DocAmount = Null
Else
Me.DocAmount = [forms]![form2]![DocAmount]
End If
Does anyone know how to go about making a query-based form or report that allows what I've described above to take place? Or maybe this should not be done via a query?
Thanks!!
Put the IF statement into to data source for me.docamount
OR use a case statement in the query itself
select case docstatus when 'Not in workflow' then null else docamount end

Crystal Reports equivalent of 'WHERE'

I'm familiar with SQL but not Crystal Reports. I'm trying to deal with an imported data set with 5 columns:
id deathDate giftDate giftAmount Dead
123 2008-01-06 2011-09-08 25.00 TRUE
456 2009-06-08 2011-10-13 10.00 TRUE
789 0 2011-12-04 50.00 FALSE
...
I'm trying to do a subquery but can't figure out what the CR equivalent of WHERE in SQL would be. I'd like to do something along the line of:
SELECT count(id) from tab1 where dead=TRUE
Any suggestions?
As Conrad and dotjoe have observed, the Crystal equivalent of the sql where clause is the Select Expert - you should be able to find this on the Report menu.
If you need to include both true and false Dead records in the detail section, but want a total for only those records where Dead is true, the simplest way to do this would be to set up a formula item. To do so:
Right-click on the Formula Fields option in the Field Explorer and select New... .
Enter a suitable formula field name, like DeadCount.
In the Formula editor, enter a formula like the following (assuming Dead is a string):
If {tab1.Dead} = 'TRUE' then 1
Use the x-2 button (or Alt-C) to check that the formula does not have any errors, then press the Save and Close button to exit the formula editor.
Drag and drop the new formula field from the Field Explorer onto anywhere in the report.
Right-click on the formula field that you have just added to the report and select Insert > Summary... from the menu.
In the Insert Summary dialog, specify the Summary operation as Sum and the Summary location as Grand Total (Report Footer), then click OK. A summarised field, labelled something like Sum of #DeadCount, should appear in the Report Footer. (You should now remove the un-summarised formula field from where you placed it in the report design area.)
This technique is essentially similar to including a summed case value in a sql query - something like: select sum(case when Dead = 'TRUE' then 1 end) as DeadCount from tab1
Add this to the record selection formula...
{datasetname.Dead} = true
//note: I'm not sure what data type that is but CR uses bool for bit and XSD bool
Then add a summary field to the report footer which does the count(id).
Or, if you need to display the dataset and only need a subquery you can use something called a "Running Total" field. In here you can do the count(id) and add the where clause to the necessary formula.

stored procedure sql case or if else displaying all records using single query

ok i have
ID TITLE CONTENT DATEPUBLISH DATEEXPIRED PUBLISH as my content table
i want to display all records in the table based upon these conditions using one query.
i have datepublish as a textbox ,dateexpired as a textbox and publish as a checkbox.
1) if i enter datepublish the content will be publish without expiry.
2) if i enter datexpire the content will start publishing straight away and will expire when it reaches the expiry date
3) if i enter both dates then the content will start on the datepublish and will expire when dateexpired
the other thing is that
4) if i checked publish then it will bypass the dates.
how can i display all records using a single query?.( i am able to do it with cursor)
SELECT *
FROM Table
WHERE ((#datePublish IS NULL OR Table.datePublish > #datePublish)
AND (#dateExpired IS NULL OR Table.dateExpired < #dateExpired))
OR #published = 1
If either of your date values is empty, then you pass NULL to your stored procedure for that parameter (thus that parameter won't restrict the result set), and #published = 1 if the checkbox is checked.