Solved

SSRS 2008, multivalued parameter, SQL Query

Posted on 2014-11-30
6
145 Views
Last Modified: 2014-12-14
Hi,

a.
 I have a drop down multivalued parameter. the items in this parameter must be hard coded and not coming from a dataabase.
 e.g.:  
All
CurrentFriday
 NextFriday

how can this be done?

b.
 I want to hide the 'Select All' which is placed by default when you select multivalued parameter. How can this be done?

c.
when I send it to stored procedure, I need to check an Enddate column.
if enddate is less than today then set columnX to 'currentFriday' otherwise to next friday.
I need to do it within the query.

Thanks in advance
0
Comment
Question by:shmz
  • 4
  • 2
6 Comments
 
LVL 37

Assisted Solution

by:ValentinoV
ValentinoV earned 250 total points
ID: 40473275
a: I usually hardcode this in a query then configure the report parameter based on the dataset, easier for maintenance:

select 'Current Friday' as Label, 'CF' as Code
union all
select 'Next Friday', 'NF'

b: you can't, it comes for free when you check the multi-value checkbox.  Why would that be an issue? (this only has effect on the user interface)

c: check this

SET DATEFIRST 7;    
declare @enddate date = '2014-01-01';
declare @currentdate date = getdate();

select case when @enddate < getdate() then dateadd(dd,6-datepart(dw,@currentdate)-7,@currentdate) 
	else dateadd(dd,6-datepart(dw,@currentdate),@currentdate) end CF_or_NF
	, dateadd(dd,6-datepart(dw,@currentdate),@currentdate) as NextFriday
	, dateadd(dd,6-datepart(dw,@currentdate)-7,@currentdate) as CurrentFriday

Open in new window

0
 

Author Comment

by:shmz
ID: 40473631
Thank but I don't need to do date calculations.
I have a column of type udt_fuzzydate(char 8)

I have to do conversion bef
0
 

Author Comment

by:shmz
ID: 40473657
Thank but I don't need to do date calculations.

I have 2 issues:

I have a column of type udt_fuzzydate(char 8)

I have to do conversion before comparing, here is actual code but it doesn't work:
(Error: conversion of varchar datatype to a datetime data type resulted in an out of range value)
Select x
, y
, z
, (Select case when
( isdate(end date)= 1 and convert(datetime, enddate) > getdate()) or
(isdate(end date)= 1 and convert(datetime, enddate) = null)
Then 'current'
Else 'next'
End) as type
,.....
From tble1,.....

Other issue is that I pass the type (current, next or all) from report parameter to query and now I need to check which record in above conversion and comparison matches the selected parameter in the report???
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 37

Expert Comment

by:ValentinoV
ID: 40475362
"Thank but I don't need to do date calculations."

Erm...

"if enddate is less than today"

That IS a date calculation...

I understand that the data type of enddate is udt_fuzzydate(char 8)?  What does such a value look like?

PS: I recommend you to focus on one issue per question.  In this one I see at least three...
0
 

Accepted Solution

by:
shmz earned 0 total points
ID: 40490282
Thanks for your a and b.

c. this is how I solved it:

(select case when isdate(ENDDATE)=1 then (case when convert(datetime, ENDDATE) > getdate()
                                                                              then 1
                                                                              else 2
                                                                                end)
                                                              else 1  
                                                              end) as X
0
 

Author Closing Comment

by:shmz
ID: 40498739
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now