Solved

SSRS 2008, multivalued parameter, SQL Query

Posted on 2014-11-30
6
147 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

896 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

17 Experts available now in Live!

Get 1:1 Help Now