Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Report 报表生成器3.0中的中值函数_Report_Builder_Median_Reportbuilder3.0_Reportbuilder - Fatal编程技术网

Report 报表生成器3.0中的中值函数

Report 报表生成器3.0中的中值函数,report,builder,median,reportbuilder3.0,reportbuilder,Report,Builder,Median,Reportbuilder3.0,Reportbuilder,我需要在MS Report Builder 3.0中执行中位数计算,考虑到我的原始值是 区域-Etab-值 Abc-Def-10 Abc-Def-12 Ged-Tae-1 我需要按地区和Etab分组 我通过以下方式使用哈希表获得了正确的值: Dim theHashTable As New System.Collections.Hashtable Function AddValue(theRapport As String, theRegion As String, theEtab As Str

我需要在MS Report Builder 3.0中执行中位数计算,考虑到我的原始值是

区域-Etab-值

Abc-Def-10

Abc-Def-12

Ged-Tae-1

我需要按地区和Etab分组

我通过以下方式使用哈希表获得了正确的值:

Dim theHashTable As New System.Collections.Hashtable

Function AddValue(theRapport As String, theRegion As String, theEtab As String, theRow As String, theValue As String) As Integer
    Dim num As Integer
    num = 0
    If (theHashTable Is Nothing) Then
        theHashTable = New System.Collections.Hashtable
    End If
    If Integer.TryParse(theValue, num) Then
        If (num >= 0) Then
            If (theHashTable.ContainsKey(theRapport)) Then
                Dim regionHT As New System.Collections.Hashtable
                regionHT = theHashTable(theRapport)
                If (regionHT.ContainsKey(theRegion)) Then
                    Dim etabHT As New System.Collections.Hashtable
                    etabHT = regionHT(theRegion)
                    If (etabHT.ContainsKey(theEtab)) Then
                        Dim valueHT As New System.Collections.Hashtable
                        valueHT = etabHT(theEtab)
                        If (Not valueHT.ContainsKey(theRow)) Then
                            valueHT.Add(theRow, theValue)
                        End If
                        etabHT(theEtab) = valueHT
                    Else
                        Dim valueHT As New System.Collections.Hashtable
                        valueHT.Add(theRow, theValue)
                        etabHT.Add(theEtab, valueHT)
                    End If
                    regionHT(theRegion) = etabHT
                Else
                    Dim etabHT As New System.Collections.Hashtable
                    Dim valueHT As New System.Collections.Hashtable
                    valueHT.Add(theRow, theValue)
                    etabHT.Add(theEtab, valueHT)
                    regionHT.Add(theRegion, etabHT)
                End If
                theHashTable(theRapport) = regionHT
            Else
                Dim regionHT As New System.Collections.Hashtable
                Dim etabHT As New System.Collections.Hashtable
                Dim valueHT As New System.Collections.Hashtable
                valueHT.Add(theRow, theValue)
                etabHT.Add(theEtab, valueHT)
                regionHT.Add(theRegion, etabHT)
                theHashTable.Add(theRapport, regionHT)
            End If
        End If
    End If

    Return num
End Function

Function GetMedian(theRapport As String, theRegion As String, theEtab As String) As String

    Dim arrayInt As New System.Collections.ArrayList
    arrayInt = GetArray(theRapport, theRegion, theEtab)
    arrayInt.Sort()
    Dim mid As Double = (arrayInt.Count - 1) / 2.0
    Dim midInt As Integer = mid
    Dim mid2Int As Integer = mid + 0.5
    If arrayInt.Count >= 2 Then
        Return ((arrayInt(midInt) + arrayInt(mid2Int)) / 2).ToString()
    ElseIf arrayInt.Count = 1 Then
        Return arrayInt(0)
    Else
        Return ""
    End If
End Function

Function GetQ1(theRapport As String, theRegion As String, theEtab As String) As String

    Dim arrayInt As New System.Collections.ArrayList
    arrayInt = GetArray(theRapport, theRegion, theEtab)
    arrayInt.Sort()
    Dim taille As Integer = arrayInt.Count
    If (taille = 1) Then
        Return arrayInt(0)
    ElseIf ((taille Mod 2) = 0 And taille > 0) Then
        Dim mid1 As Integer = taille / 2
        Dim midmid As Integer = mid1 / 2
        If (mid1 Mod 2 = 0) Then
            Return ((arrayInt(midmid - 1) + arrayInt(midmid)) / 2).ToString()
        Else
            Return (arrayInt(midmid)).ToString()
        End If
    ElseIf (taille = 1) Then
        Return arrayInt(1)
    ElseIf ((taille - 1) Mod 4 = 0) Then
        Dim n As Integer = (taille - 1) / 4
        Return ((arrayInt(n - 1) * 0.25 + arrayInt(n) * 0.75)).ToString()
    ElseIf ((taille - 3) Mod 4 = 0) Then
        Dim n As Integer = (taille - 3) / 4
        Return ((arrayInt(n) * 0.75 + arrayInt(n + 1) * 0.25)).ToString()
    Else
        Return ""
    End If

End Function

Function GetQ3(theRapport As String, theRegion As String, theEtab As String) As String

    Dim arrayInt As New System.Collections.ArrayList
    arrayInt = GetArray(theRapport, theRegion, theEtab)
    arrayInt.Sort()
    Dim taille As Integer = arrayInt.Count
    If (taille = 1) Then
        Return arrayInt(0)
    ElseIf ((taille Mod 2) = 0 And taille > 0) Then
        Dim mid1 As Integer = taille / 2
        Dim midmid As Integer = mid1 / 2
        If (mid1 Mod 2 = 0) Then
            Return ((arrayInt(mid1 + midmid - 1) + arrayInt(mid1 + midmid)) / 2).ToString()
        Else
            Return (arrayInt(mid1 + midmid)).ToString()
        End If
    ElseIf (taille = 1) Then
        Return arrayInt(1)
    ElseIf ((taille - 1) Mod 4 = 0) Then
        Dim n As Integer = (taille - 1) / 4
        Return ((arrayInt(3 * n) * 0.75 + arrayInt(3 * n + 1) * 0.25)).ToString()
    ElseIf ((taille - 3) Mod 4 = 0) Then
        Dim n As Integer = (taille - 3) / 4
        Return ((arrayInt(3 * n + 1) * 0.25 + arrayInt(3 * n + 2) * 0.75)).ToString()
    Else
        Return ""
    End If

End Function

Function GetArray(theRapport As String, theRegion As String, theEtab As String) As System.Collections.ArrayList
    Dim arrayInt As New System.Collections.ArrayList
    If (theHashTable Is Nothing Or theHashTable.Count = 0) Then
        Return arrayInt
    Else
        If (theHashTable.ContainsKey(theRapport)) Then
            Dim regionHT As System.Collections.Hashtable
            regionHT = theHashTable(theRapport)
            If (theRegion = "" And theEtab = "") Then
                For Each value As System.Collections.Hashtable In regionHT.Values
                    For Each value2 As System.Collections.Hashtable In value.Values
                        For Each valeur As Integer In value2.Values
                            arrayInt.Add(valeur)
                        Next
                    Next
                Next
            ElseIf (regionHT.ContainsKey(theRegion) And theEtab = "") Then
                Dim etabHT As System.Collections.Hashtable
                etabHT = regionHT(theRegion)
                For Each value As System.Collections.Hashtable In etabHT.Values
                    For Each valeur As Integer In value.Values
                        arrayInt.Add(valeur)
                    Next
                Next
            ElseIf (regionHT.ContainsKey(theRegion) And theEtab <> "") Then
                Dim etabHT As System.Collections.Hashtable
                etabHT = regionHT(theRegion)
                If Not (etabHT Is Nothing Or etabHT.Count = 0) Then
                    If (etabHT.ContainsKey(theEtab)) Then
                        Dim valuesHT As System.Collections.Hashtable
                        valuesHT = etabHT(theEtab)
                        For Each value As Integer In valuesHT.Values
                            arrayInt.Add(value)
                        Next
                    End If
                End If
            End If
        End If

        Return arrayInt
    End If
End Function

Function PrintArray(theRapport As String, theRegion As String, theEtab As String) As String
    Dim arrayInt As New System.Collections.ArrayList
    arrayInt = GetArray(theRapport, theRegion, theEtab)
    Dim str As String = ""
    If (arrayInt.Count > 0) Then
        str = String.Join(" | ", arrayInt.ToArray)
    Else
        str = " "
    End If
    Return str
End Function
第一个哈希表用于需要中值的报告的不同表

然后,我使用以下命令添加值

代码。AddValue3_2,字段!区域。值,字段!幸福,价值,领域!行数。值,字段!价值,价值

然后我用这些表达式得到中值

=Code.GetMedian3_2,字段!区域。值,字段!幸福。价值

=Code.GetMedian3_2,字段!地区,价值,

=Code.GetMedian3_2

我试着将AddValue函数放在一个隐藏表和表的摘要行中。 我得到了正确的值,但一旦我展开或折叠一行,所有内容都将变为空白。如何保存该值,或者将AddValue函数放在何处,以确保对报表中的每个表的每个操作都调用它


谢谢

更新了问题我使用GetMiddian和AddValue的聚合修复了问题,即:MaxCode.AddValue3_2,字段!区域。值,字段!幸福,价值,领域!行数。值,字段!隐藏列上的Value.Value和=MaxCode.GetMedian3_2,字段!区域。值,字段!etablisement.显示中间值的值