• wendy elizabeth (10/16/2013)


    Thanks for your response! I have a few additional questions to ask you about your comment,

    "1. Create the parameter and make sure to allow nulls

    2. Add an available value as (NULL) either within the query (if using a dataset) or hard-coded" which are:

    a. In SSRS how do you make certain that the SSRS report allows for null values?

    b. What benefit do I get by allowing NULL to be an available value? How do you specify that NULL is an available value?

    c. If I specify NULL as an available value, do I need to specify other values as being available?

    d. Just for my knowledge, I would like to know how to specify NULL is an available value in code.

    General comments:

    When using a parameter it is usual to help the user by having a query to show the possible choices. To do this you would normally add a dataset to the SSRS report that will have something like :

    SELECT DISTINCT CourseName, CourseCode

    FROM dbo.CourseList

    To add the NULL (or unspecified) option as shown below. The CourseName in this example will be shown to the end user. The CourseCode is used for the value.

    SELECT DISTINCT CourseName, CourseCode

    FROM dbo.CourseList

    UNION

    SELECT 'NULL',-1

    You can use this in your dataset query as below. This would show the delegates for a specific course or all delegates if the NULL option (meaning unspecified) was chosen.

    SELECT *

    FROM dbo.DelegatesList

    WHERE CourseCode = @CourseCode OR (@CourseCode = -1)

    Answers to your questions:

    a. In SSRS how do you make certain that the SSRS report allows for null values?

    The parameter has an option to allow nulls on the first tab of the parameter settings dialog box. Check (tick) this to allow nulls.

    b. What benefit do I get by allowing NULL to be an available value? How do you specify that NULL is an available value?

    If you want the end users to be allowed to select NULL from a list then you must have it in the allowable choices list. Why would you need it is down to your requirement for the end users to either select a course or a grade i.e. one of those should be NULL.

    c. If I specify NULL as an available value, do I need to specify other values as being available?

    Yes see general comments above.

    d. Just for my knowledge, I would like to know how to specify NULL is an available value in code.[/quote]

    See general comments above.

    From your general requirement from the first post, they query could be rewritten to include both @Grade and @Course as below. This would cover the cases :

    a) return all delegates for a course regardless of grade

    b) return all delegates who attained a grade regardless of course

    c) return all delegates who attained a grade in a selected course

    SELECT *

    FROM dbo.Delegate

    WHERE

    (CourseCode = @CourseCode OR @CourseCode = -1)

    AND (Grade = @Grade OR @Grade = -1)

    Fitz