如何选择符合行组的“First(Fields ...)”和“Last(Fields ..)”之间的行值?

时间:2012-05-30 20:26:03

标签: ssrs-2008 reporting-services ssrs-tablix ssrs-grouping

使用SSRS 2008R2。

目前,我有一个select语句,它查询几个表并返回一堆分层数据。

1 Store-> 1+节 - > 1 +项

返回的数据集类似于此类(加上其他20列):

Store_num | Section_num | Section_Name | Year_Calc | Item_name    | Item_Num
  4542    |   32        |    Fruits    |    1      |   Apple      |   1
  4542    |   32        |    Fruits    |    2      |   Apple      |   1
  4542    |   32        |    Fruits    |    3      |   Apple      |   1
  4542    |   32        |    Fruits    |    4      |   Apple      |   1
  4542    |   32        |    Fruits    |    5      |   Apple      |   1
  4542    |   32        |    Fruits    |    1      |   Berry      |   2
  4542    |   32        |    Fruits    |    2      |   Berry      |   2
  4542    |   32        |    Fruits    |    3      |   Berry      |   2
  4542    |   32        |    Fruits    |    4      |   Berry      |   2
  4542    |   32        |    Fruits    |    5      |   Berry      |   2
  4542    |   32        |    Fruits    |    1      |   Orange     |   3
  4542    |   32        |    Fruits    |    2      |   Orange     |   3
  4542    |   32        |    Fruits    |    3      |   Orange     |   3
  4542    |   32        |    Fruits    |    4      |   Orange     |   3
  4542    |   32        |    Fruits    |    5      |   Orange     |   3
  4542    |   32        |    Fruits    |    1      |   Banana     |   4
  4542    |   32        |    Fruits    |    2      |   Banana     |   4
  4542    |   32        |    Fruits    |    3      |   Banana     |   4
  4542    |   32        |    Fruits    |    4      |   Banana     |   4
  4542    |   32        |    Fruits    |    5      |   Banana     |   4
  4542    |   32        |    Fruits    |    1      |   Watermelon |   5
  4542    |   32        |    Fruits    |    2      |   Watermelon |   5
  4542    |   32        |    Fruits    |    3      |   Watermelon |   5
  4542    |   32        |    Fruits    |    4      |   Watermelon |   5
  4542    |   32        |    Fruits    |    5      |   Watermelon |   5
  4542    |   33        | Vegetables   |    1      |   Esparagus  |   12
  4542    |   33        | Vegetables   |    2      |   Esparagus  |   12
  4542    |   33        | Vegetables   |    3      |   Esparagus  |   12
  4542    |   33        | Vegetables   |    4      |   Esparagus  |   12
  4542    |   33        | Vegetables   |    5      |   Esparagus  |   12
  4542    |   33        | Vegetables   |    1      |   Lettuce    |   13
  4542    |   33        | Vegetables   |    2      |   Lettuce    |   13
  4542    |   33        | Vegetables   |    3      |   Lettuce    |   13
  4542    |   33        | Vegetables   |    4      |   Lettuce    |   13
  4542    |   33        | Vegetables   |    5      |   Lettuce    |   13
  4542    |   33        | Vegetables   |    1      |   Mushroom   |   14
  4542    |   33        | Vegetables   |    2      |   Mushroom   |   14
  4542    |   33        | Vegetables   |    3      |   Mushroom   |   14
  4542    |   33        | Vegetables   |    4      |   Mushroom   |   14
  4542    |   33        | Vegetables   |    5      |   Mushroom   |   14
  4542    |   33        | Vegetables   |    1      |   Tomato     |   15
  4542    |   33        | Vegetables   |    2      |   Tomato     |   15
  4542    |   33        | Vegetables   |    3      |   Tomato     |   15
  4542    |   33        | Vegetables   |    4      |   Tomato     |   15
  4542    |   33        | Vegetables   |    5      |   Tomato     |   15
  4542    |   33        | Vegetables   |    1      |   Spinach    |   16
  4542    |   33        | Vegetables   |    2      |   Spinach    |   16
  4542    |   33        | Vegetables   |    3      |   Spinach    |   16
  4542    |   33        | Vegetables   |    4      |   Spinach    |   16
  4542    |   33        | Vegetables   |    5      |   Spinach    |   16

在我的tablix中,我目前正在分配Items_num和Section_num,以便我为每个Section重复我的整个Tablix。

起初这不是一个难题,因为我刚创建了两个tablix,而多年的一个有一个列组。问题解决了。

但是,与任何工作一样,这还不够好。我需要为每个“5年计算”重复所有信息数据。

这是tablix的样子,你会理解为什么我无法找到一个好的解决方案。

+--------+--------+----------------+-------------+---------+---------+----------------+
|Store   |4542                     |Store Name:  | We Sell Groceries!                 |
+--------+--------+----------------+-------------+---------+---------+----------------+
|Section |32                       |Section Name:| Fruits                             |
+--------+--------+----------------+-------------+---------+---------+----------------+
|Item    |1                        |Item Name:   | Apple                              |
+--------+--------+----------------+-------------+---------+---------+----------------+
|                 |First(Year)     |2nd(Year)    |3rd(Year)|4th(Year)|Last(Year)      |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 1    |First(Column_10)|             |         |         |Last(Column_10) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 2    |First(Column_11)|             |         |         |Last(Column_11) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 3    |First(Column_12)|             |         |         |Last(Column_12) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 4    |First(Column_13)|             |         |         |Last(Column_13) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 5    |First(Column_14)|             |         |         |Last(Column_14) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 6    |First(Column_15)|             |         |         |Last(Column_15) |
+-----------------+----------------+-------------+---------+---------+----------------+
|Calculation 7    |First(Column_16)|             |         |         |Last(Column_16) |
+-----------------+----------------+-------------+---------+---------+----------------+

我有5个静态列,我无法找到从我的数据集中获取“第2,第3和第4”值的方法。

使用查找功能在整个数据集上不起作用,并且不符合我当前应用的行组(对整个Tablix)

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

因为我之前尝试过1个部分和1个项目。我恢复了那个设计并创建了一个新报告,其中一个子报告隐藏在Tablix中,并在那里完成了分组。

在实际的子报表中,我创建了两个Tablix。一个包含计算上方的所有数据,另一个包含计算结果(根据列组增长)

答案:使用子报告