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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors