【问题标题】:SSRS expression - query from dataset, with groupSSRS 表达式 - 从数据集中查询,带组
【发布时间】:2014-10-21 04:14:08
【问题描述】:

假设对于每个学生,我有一个考试记录,我需要计算每个问题、每组问题和总考试(每个学生)的百分比排名...。

针对每个问题、每组问题和总考试,按照我的需要去做:
1) x = 分数(我当然有)
2) x 以上分数的计数
3) 分数等于 x
4)总分的计数

这样做看起来我需要在 T-SQL 查询中为我使用子选择。计算大数据集中的所有内容并使用它。

有没有办法在 SSRS 中实现这一点

【问题讨论】:

    标签: sql reporting-services dataset


    【解决方案1】:

    我发现了一篇关于 SSRS 中百分位函数的有趣帖子,我会尝试一下。

    https://www.katieandemil.com/ssrs-percentile-function-2008-r2-calculation-custom-code-example?tab=article

    我不得不创建另一个函数来返回排名,但主要思想就在那里:

    Public Shared Dim values As System.Collections.ArrayList
    
    Public Shared Function AddValue(ByVal newValue As Decimal) As Decimal 
        If (values Is Nothing) Then
           values = New System.Collections.ArrayList()
        End If
        values.Add(newValue)
        AddValue = values.Count
    End Function
    
    Public Shared Function GetRankPercentile(ByVal CurrentValue As Decimal) As Decimal
        Dim countTotal As Integer = values.Count 'nombre total de données
        Dim countGreater As Integer = 0
        Dim countEqual As Integer = 0
        Dim iLoop As Integer
        Dim tmpArray as system.array
        tmpArray = values.ToArray()
    
        For iLoop = LBound(tmpArray) To UBound(tmpArray)
           If tmpArray(iLoop)  CurrentValue Then countGreater = countGreater + 1
           If tmpArray(iLoop) = CurrentValue Then countEqual = countEqual + 1
        Next
    
        GetRankPercentile = Math.Ceiling((countGreater + (countEqual / 2)) / countTotal * 5)
    End Function
    

    【讨论】:

      猜你喜欢
      • 2014-08-22
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多