Tablix /矩阵中具有动态列的数据集 [英] Dataset with dynamic columns in tablix/matrix

查看:106
本文介绍了Tablix /矩阵中具有动态列的数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,可以包含5列,即6、7、10、20甚至100列。
至少有两个是静态的,其余是动态的(我根据一个表进行缩放)

I have a dataset that can come with 5 columns, columns 6, 7, 10, 20, or even 100. At least two are static, the remaining are dynamic (am making a scale according to a table exists in the database).

如何在Reporting Services中实现此功能?

How can I implement this in Reporting Services?

如何指定tablix字段的值是动态的吗?

How do I specify the field of tablix that the value is dynamic?

最终结果将是:

|   TITLE | ENUNCIATION | GOOD | VERY GOOD | BAD | VERY BAD |
-------------------------------------------------------------
| title 1 |  question 1 |    5 |         3 |   1 |        0 |
| title 2 |  question 2 |    1 |         0 |   3 |        0 |
| title 3 |  question 3 |    0 |         0 |   1 |        0 |

|   TITLE | ENUNCIATION |   1  |     2     |  3  |     4    |
-------------------------------------------------------------
| title 1 |  question 1 |    5 |         3 |   1 |        0 |
| title 2 |  question 2 |    1 |         0 |   3 |        0 |
| title 3 |  question 3 |    0 |         0 |   1 |        0 |

注意:前两个是静态的,其余是动态的。

Note: The first two are static, the remaining dynamics.

编辑:

我有此表:

|   ID_SCALE  | ID_SCALE_ENTRY   | NAME          |
--------------------------------------------------
|      1       |        1        |    GOOD       |    
|      1       |        2        |    VERY GOOD  |   
|      1       |        3        |    BAD        |   
|      1       |        4        |    VERY BAD   |    
|      2       |        1        |       1       |    
|      2       |        2        |       2       |
|      2       |        3        |       3       |
|      2       |        4        |       4       |
|      2       |        5        |       5       |
|      2       |        6        |       6       |
|      2       |        7        |       7       |    

编辑+注意:
我想完全显示为如第一张表所示。问题是动态创建了(好,很好,不好,不好,1、2、3、4)字段,并且无法在Tablix中指定。

EDIT + NOTE: I want to show exactly as shown in the first table. The problem is that (Good, Very Good, Bad, Very Bad, 1, 2, 3, 4) fields are created dynamically and it is not possible to specify this in the tablix.

一个例子:当我想要数据集的字段值时,我将这个表达式设为Fields!Good.value,但是现在想象它不是 Good而是 1 Fields! Good.value不再存在。结论是一个带有动态列的数据集。

An example: When I want the field value of the dataset, i put this expression Fields!Good.value But now imagine that it is not "Good" but "1" Fields! Good.value no longer exists. Conclusion, is a dataset with dynamic columns.

推荐答案

首先-您应该为此使用Matrix。

First - You should use Matrix for that.

第二-要完成所需的操作,在返回数据的方法中,您必须至少返回三个数据字段。

Second - To accomplish what you want, in the method you return the data you must return at least three data fields.

例如:

ColDescription - Column description
StaticRowDescription - Row description / static column value
Value - The real value for that column/row combination.

知道了吗?

您的矩阵应该然后是这样:

Your Matrix should then be like this:

| Any Text               | [ColDescription] |
| [StaticRowDescription] | [Value]          |

编辑

忘记提及在此示例中,任何文本都是我的静态列。您可以添加更多以满足您的需求。

Forgot to mention that Any text is my static column in this example. You can add more to match your need.

----------------------- ----------------------------------------

由于您的评论而产生的示例。

An example due to your comment.

这是在返回方法中实现的方式:

This is how you would implement in your return method:

假设您有一个静态列说明和其他(n)。

Let's say you have one static column Description and the others (n).

public IEnumerable<YourReturnClass> GetData(int param) 
{
    List<YourReturnClass> returnList = new List<YourReturnClass>();
    foreach (var row in allYourRows())
    {
        foreach (var col in row.getColumns())
        {
            returnList.add(new YourReturnClass(){
                StaticRowDescription = row.Description,
                ColDescription = col.Description,
                Value = myValueAccordingToCurrentColumnXRow()
            });
        }
    }

    return returnList;
}

这是您的矩阵:

| Description            | [ColDescription] |
| [StaticRowDescription] | [Value]          |

那样,如果您在 allYourRows()的描述为费用,两列的名称分别为 Gas和 Electricity,您将以此作为矩阵结果:

That way if you had one row in allYourRows() with a description "Expenses" and two columns with the names "Gas" and "Electricity" you would have this as your matrix result:

| Description | Gas | Electricity |
-----------------------------------
| Expenses    | 25  | 150         |

更好吗?

这只是为了解释矩阵的工作原理,您获取数据的方式可能与肖像数据不同。

This is just to explain how matrix works, the way you get your data might be different than the one portraited.

报告(RDL)相同,唯一的变化是如何获取数据。如果您有这样一个表:
(这是数据库中的表(用于存储数据的表))

The report (RDL) will be the same, the only change is in how you get your data. If you have a table like this: (this would be a table from your database (where you have stored your data))

| RowDescription | DynamicColumnHeader | Value |
------------------------------------------------
| Year 2013      | January             | 500   |
| Year 2013      | February            | 850   |
| Year 2013      | March               | 265   |
| Year 2014      | February            | 965   |

然后您的报告将如下所示:

Then your report would look like this:

| Description | January | February | March|
-------------------------------------------
| Year 2013   | 500     | 850      | 265  |
| Year 2014   |         | 965      |      |

知道了吗?

我已附加报表外观的图像:

I attached an image of how your report would look like:

新编辑:

|   TITLE | ENUNCIATION    | [NAME]                          |
-------------------------------------------------------------
| [title] |  [enunciation] |  [ID_SCALE] OR [ID_SCALE_ENTRY] |

*或乘法,总和等...

*or a multiplication, sum, etc...

基于最后评论的编辑:

|   TITLE | ENUNCIATION    | [NAME]                          |
-------------------------------------------------------------
| [title] |  [enunciation] | [Count(NAME)]                   |

是吗?

这篇关于Tablix /矩阵中具有动态列的数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆