【问题标题】:How can I select row values that are in between "First(Fields...)" and "Last(Fields..)" that adhere to row groups?如何选择符合行组的“First(Fields...)”和“Last(Fields..)”之间的行值?
【发布时间】:2012-06-02 00:30:13
【问题描述】:

使用 SSRS 2008R2。

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

1 商店-> 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 的每个 Item 重复我的整个 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”值的方法。

使用 Lookup 函数不起作用,因为它适用于整个数据集,并且不符合我当前应用的行组(适用于整个 tablix)

有什么想法吗?

【问题讨论】:

  • 为什么你要设置 First(column_name) 你不需要 First() 方法来显示你的数据,你能把第一个去掉吗并检查结果。告诉我
  • 首先返回“年份”等于 1 时的值(对于部分中的每个项目)。当然,没有它仍然会返回相同的值,但这不是我遇到的问题。我说的是在 Year = 2,3,4 时获取值。

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


【解决方案1】:

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

在实际的子报表中,我创建了两个 tablix。一个包含计算上方的所有数据,一个包含计算下方的所有数据(将基于列组增长)

回答:使用了子报告

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-02
    • 2021-03-24
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    相关资源
    最近更新 更多