【问题标题】:AVG multiple Lookup expression in SSRS (Visual Studio)SSRS (Visual Studio) 中的 AVG 多重查找表达式
【发布时间】:2017-02-03 17:04:25
【问题描述】:

如果我有 6 个人,每个人都有 2 个调查回复。每个调查回复有 10 个问题。在我的数据集上,我有一列包含所有问题(1、2、3、4....),第二列包含与问题相对应的所有答案。见下图。

我正在尝试平均每个人的问题 1、2、5 和 8 的分数。

我在 Report Properties 中添加了一个 VB 代码并使用下面的表达式并能够获得问题 1 的 AVG。有没有办法合并问题 2、5 和 8 的 AVG?

=Code.AvgLookup(
  LookupSet(
    Fields!Instructorname.Value & "1. Course achieved?",
    Fields!Instructorname.Value & Fields!Questions.Value,
    Fields!Scores.Value, "DataSet1")
 )

问答布局

【问题讨论】:

    标签: vb.net visual-studio-2012 reporting-services crystal-reports ssrs-2012


    【解决方案1】:

    您的函数似乎只需要一个问题进行计算。注意 LookupSet() 返回一个 Object[],尽管在 SSRS 中没有任何明确的方法来连接/联合数组,但使用 JOINSPLIT 函数有一个技巧:

    =Code.AvgLookup(split(
      join(
        LookupSet(Fields!Instructorname.Value & "1. Course achieved?",
          Fields!Instructorname.Value & Fields!Questions.Value,
          Fields!Key.Value,Fields!Code.Value,"DataSet1"),","
      )
      & "," &
      join(
        LookupSet(Fields!Instructorname.Value & "2. Content was easy to understand",
          Fields!Instructorname.Value & Fields!Questions.Value,
          Fields!Key.Value,Fields!Code.Value,"DataSet1"),","
      )
      & "," &
      join(
        LookupSet(Fields!Instructorname.Value & "5. Material was easy to understand",
          Fields!Instructorname.Value & Fields!Questions.Value,
          Fields!Key.Value,Fields!Code.Value,"DataSet1"),","
      )
      & "," &
      ... -> join(lookupset(...) for question 8 and so on.
    ,","))
    

    尽管可行,但处理您的报告可能需要更多时间。处理此问题的正确方法应该是创建适当的表结构和关系,让您可以直接从源中获取报告中所需的数据。

    如果这有帮助,请告诉我。

    【讨论】:

    猜你喜欢
    • 2021-08-10
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多