SQL Reporting services 2005

wwestendorp
Member Posts: 178
I have a question,
If I have e table where in the filter i can select all or just a single item. How should I do that (NOT using the Multi Value) option in the parameters?
If I have e table where in the filter i can select all or just a single item. How should I do that (NOT using the Multi Value) option in the parameters?
0
Comments
-
Hi,
You need to add extra one value to your drop-down parameter values list, called '_all_' for example (whatever, but unique to the rest of values), and in SQL query build your WHERE clause like that:WHERE (field=parameter) OR (parameter='_all_')
This is only one of many possible solutions.
Regards,
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I found on the web another solution which is more or less the same, thanks.
"All" Parameter Value
Question:
How can I enable users to select "All" as the value of a query parameter?
Answer:
The simplest way is to modify your query to accept nulls and map "All" to null.
Step 1: Start with a report that already has a parameterized query and Valid Values queries.
Step 2: Edit your base query to account for nulls.
Whever you have something like this:
... AND Field = @Parameter ...
Replace it with this:
... AND (Field = @Parameter OR @Parameter is NULL) ...
Step 3: Edit your Valid Values queries to insert an explicit "All" and separate ids from labels
For example, for this original query:
SELECT name FROM productcategory
Change it to this:
SELECT name as ID, name as Label FROM productcategory
UNION
SELECT Null as ID, 'All' as Label
Step 4: Update the report parameters
Mark each parameter as nullable
Change the valid values settings to account for the new field names (if needed).
Step 5 (Optional): Update Valid Values queries to account for nulls.
If you have hierarchical parameters, in some cases, you may want the dependent parameters to be independently selectable when the parent parameter's value is "All". In this case, repeat step 2 for each of your Valid Values queries. Note: Don't do this if you have extremely large numbers of possible values, as performance will suffer and your users wouldn't be able to nagivate an excessively long list anyhow.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions