开发者

SSRS 2005 Passing Different Parameters to the Same Data Set

开发者 https://www.devze.com 2023-03-05 00:22 出处:网络
I am creating a report in SSRS 2005 with a number of data sets. An example could be the number of trucks delivering boxes of goods and how many boxes are being delivered for each con开发者_StackOverfl

I am creating a report in SSRS 2005 with a number of data sets. An example could be the number of trucks delivering boxes of goods and how many boxes are being delivered for each con开发者_StackOverflowvoy. The trucks have a departure time and may be traveling for a long time before reaching their destination (and I want to see how many trucks are en route). An example result set might look like this:

+---------------------+------------+------------+------------+          
|                     |   Current  |     MTD    |     YTD    |
+---------------------+------------+------------+------------+
| Convoy 1 | # Trucks |      3     |      0     |     16     |
|          | Boxes    |     150    |      0     |    1005    |
+----------+----------+------------+------------+------------+
| Convoy 2 | # Trucks |      0     |     12     |      8     |
|          | Boxes    |      0     |     144    |     113    |
+----------+----------+------------+------------+------------+
| Convoy 3 | # Trucks |      0     |     0      |      0     |
|          | Boxes    |      0     |     0      |      0     |
+----------+----------+------------+------------+------------+

I have been asked to put the sql in the report and not use stored procs or views.

All convoys must show up in the result set even if there are no trucks making deliveries at the time (as in Convoy 3). What I am currently doing for queries is to find all of the convoys and then left join to each of the date ranges. For example, the pseudo-query is:

select a.convoy_name, current.trucks, current.weight, mtd.trucks, mtd.weight, ytd.trucks, ytd.weight
from(
  (get all convoys) a
  left join
  (get trucks and boxes for current date) current
  on a.something = current.something
  left join
  (get trucks and boxes for mtd) mtd
  on a.something = mtd.something
  left join
  (get trucks and boxes for ytd) ytd
  on a.something = ytd.something
)

The only difference between the date queries is the start date. What I would love to be able to do is to create a generic query I could pass the start date into and get back either the current, mtd, or ytd results (as if I were using a stored proc). Someone posted a similar issue here, but it was not answered.

Is there a way to do this is SSRS 2005? (And I'm curious to know if it is possible in later versions as well).

I would rather not add a bunch more data sets as one of my reports already has about 10.


I'm not entirely sure I understand your question (Sorry!). Looking at the other question linked it looks like they're hoping for something like the Excel SUMIF command where they don't filter data at the query level but instead filter at the report level. This is possible with SSRS 2005 by creating a parameter which is not used in the query and then filtering at the group detail level. Does this come near to answering your question?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号