sql server reporting services:
I've got a report that prompts the user for a few inputs through parameters. One of the fields is "Shift". The values are 1,2 or 3 and the user types what they want. Its not a drop down. What I would like to do is select all shifts if the user leaves it blank or selects "All" or whatever. I've searched other solutions here but keep running into a problem with "All" not being a valid option type. Should I add a new parameter or modify the dataset. What should I put in there? The data is coming from 3 different tables so forgive the cumbersome query. SELECT dbo.tblDetail.Asset, dbo.tblDetail.OperDate, dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, SUM(dbo.tblDTEvents.Duration) AS SumDur, dbo.tblDetail.Shift FROM dbo.tblDTEvents INNER JOIN dbo.tblDetail ON dbo.tblDTEvents.RecordID = dbo.tblDetail.RecordID INNER JOIN dbo.tblDTCodes ON dbo.tblDTEvents.Code = dbo.tblDTCodes.Code WHERE (dbo.tblDetail.Shift = @Shift) AND (dbo.tblDetail.Asset = @Asset) AND (dbo.tblDetail.OperDate = @Date) GROUP BY dbo.tblDetail.Asset, dbo.tblDetail.OperDate, dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, dbo.tblDetail.Shift ORDER BY SUM(dbo.tblDTEvents.Duration) DESC
Assuming you are using 2005... For the parameter @Shift check the "multi-value" checkbox. Set the available values to non-queries and set the label/value as 1/1, 2/2, 3/3 Change your query to read dbo.tblDetailShift IN (@shift) This will create a drop down box and they can choose which shifts they want to include. Do not allow "blank" or "null"
I'm making some assumptions about your setup, but how about tweaking the where clause to something like; (@Shift is null or dbo.tblDetail.Shift = @Shift) You might need to make sure that @shift is a numeric parameter, not character, so that 'blank' means 'null'. Regards, Rhys [quoted text, click to view] On Sep 20, 2:04 pm, Bruce Lawrence <BL32...@gmail.com> wrote: > I've got a report that prompts the user for a few inputs through > parameters. > > One of the fields is "Shift". The values are 1,2 or 3 and the user > types what they want. Its not a drop down. > > What I would like to do is select all shifts if the user leaves it > blank or selects "All" or whatever. I've searched other solutions > here but keep running into a problem with "All" not being a valid > option type. > > Should I add a new parameter or modify the dataset. What should I put > in there? The data is coming from 3 different tables so forgive the > cumbersome query. > > SELECT dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, > SUM(dbo.tblDTEvents.Duration) AS SumDur, > dbo.tblDetail.Shift > FROM dbo.tblDTEvents INNER JOIN > dbo.tblDetail ON dbo.tblDTEvents.RecordID = > dbo.tblDetail.RecordID INNER JOIN > dbo.tblDTCodes ON dbo.tblDTEvents.Code = > dbo.tblDTCodes.Code > WHERE (dbo.tblDetail.Shift = @Shift) AND (dbo.tblDetail.Asset = > @Asset) AND (dbo.tblDetail.OperDate = @Date) > GROUP BY dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, dbo.tblDetail.Shift > ORDER BY SUM(dbo.tblDTEvents.Duration) DESC
[quoted text, click to view] On Sep 20, 3:57 pm, RMJCS <r...@rmjcs.com> wrote: > I'm making some assumptions about your setup, but how about tweaking > the where clause to something like; > > (@Shift is null or dbo.tblDetail.Shift = @Shift) > > You might need to make sure that @shift is a numeric parameter, not > character, so that 'blank' means 'null'. > > Regards, Rhys > > On Sep 20, 2:04 pm, Bruce Lawrence <BL32...@gmail.com> wrote: > > > > > I've got a report that prompts the user for a few inputs through > > parameters. > > > One of the fields is "Shift". The values are 1,2 or 3 and the user > > types what they want. Its not a drop down. > > > What I would like to do is select all shifts if the user leaves it > > blank or selects "All" or whatever. I've searched other solutions > > here but keep running into a problem with "All" not being a valid > > option type. > > > Should I add a new parameter or modify the dataset. What should I put > > in there? The data is coming from 3 different tables so forgive the > > cumbersome query. > > > SELECT dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, > > SUM(dbo.tblDTEvents.Duration) AS SumDur, > > dbo.tblDetail.Shift > > FROM dbo.tblDTEvents INNER JOIN > > dbo.tblDetail ON dbo.tblDTEvents.RecordID = > > dbo.tblDetail.RecordID INNER JOIN > > dbo.tblDTCodes ON dbo.tblDTEvents.Code = > > dbo.tblDTCodes.Code > > WHERE (dbo.tblDetail.Shift = @Shift) AND (dbo.tblDetail.Asset = > > @Asset) AND (dbo.tblDetail.OperDate = @Date) > > GROUP BY dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, dbo.tblDetail.Shift > > ORDER BY SUM(dbo.tblDTEvents.Duration) DESC- Hide quoted text - > > - Show quoted text -
Thanks for the replies. The I tried the @Shift Is Null and it doesn't return any errors but it also doesn't return any records.
Then you propably want (@Shift = '' or dbo.tblDetail.Shift = @Shift) -- Tom Garth [quoted text, click to view] "Bruce Lawrence" wrote: > On Sep 20, 3:57 pm, RMJCS <r...@rmjcs.com> wrote: > > I'm making some assumptions about your setup, but how about tweaking > > the where clause to something like; > > > > (@Shift is null or dbo.tblDetail.Shift = @Shift) > > > > You might need to make sure that @shift is a numeric parameter, not > > character, so that 'blank' means 'null'. > > > > Regards, Rhys > > > > On Sep 20, 2:04 pm, Bruce Lawrence <BL32...@gmail.com> wrote: > > > > > > > > > I've got a report that prompts the user for a few inputs through > > > parameters. > > > > > One of the fields is "Shift". The values are 1,2 or 3 and the user > > > types what they want. Its not a drop down. > > > > > What I would like to do is select all shifts if the user leaves it > > > blank or selects "All" or whatever. I've searched other solutions > > > here but keep running into a problem with "All" not being a valid > > > option type. > > > > > Should I add a new parameter or modify the dataset. What should I put > > > in there? The data is coming from 3 different tables so forgive the > > > cumbersome query. > > > > > SELECT dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > > > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, > > > SUM(dbo.tblDTEvents.Duration) AS SumDur, > > > dbo.tblDetail.Shift > > > FROM dbo.tblDTEvents INNER JOIN > > > dbo.tblDetail ON dbo.tblDTEvents.RecordID = > > > dbo.tblDetail.RecordID INNER JOIN > > > dbo.tblDTCodes ON dbo.tblDTEvents.Code = > > > dbo.tblDTCodes.Code > > > WHERE (dbo.tblDetail.Shift = @Shift) AND (dbo.tblDetail.Asset = > > > @Asset) AND (dbo.tblDetail.OperDate = @Date) > > > GROUP BY dbo.tblDetail.Asset, dbo.tblDetail.OperDate, > > > dbo.tblDTCodes.Reason, dbo.tblDTCodes.Code, dbo.tblDetail.Shift > > > ORDER BY SUM(dbo.tblDTEvents.Duration) DESC- Hide quoted text - > > > > - Show quoted text - > > Thanks for the replies. > > The I tried the @Shift Is Null and it doesn't return any errors but it > also doesn't return any records. >
Don't see what you're looking for? Try a search.
|