Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

¿Cómo hacer SUM (DISTINCT <Filed name="">) en una consulta paginada?</Filed>

Hola

En el código en las propiedades del informe, utilizo el siguiente código:

Public Function GetDistinctSum(ByVal values As Object()) As Decimal
    distinctValues.Clear()
    For Each value In values
        If value.Rank = 4 Then
            Dim marketShare As Decimal = CDec(value.MARKET_SHARE)
            If Not distinctValues.Contains(marketShare) Then
                distinctValues.Add(marketShare)
            End If
        End If
    Next
    Dim sum As Decimal = 0
    For Each val As Decimal In distinctValues
        sum += val
    Next
    Return sum
End Function


Then I call this code as: Code.GetDistinctSum(Fields!MARKET_SHARE.Value)

I am getting below error:
There is an error on line 1 of custom code: [BC30451] 'distinctValues' is not declared. It may be inaccessible due to its protection level.
----------------------------
The definition of the report '' is invalid.
----------------------------
An error occurred during local report processing.

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Hola @sandipghosh2 ,

Parece que el error se debe a que la variable distinctValues no se ha declarado. Debe declarar distinctValues como una colección para poder usarla en la función.

Hay una publicación similar para su referencia:

Resuelto: error: [BC30451] - informe paginado - Microsoft Fabric Community

Saludos
Esteban Tao

Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors