Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

¿Cómo hacer SUM (DISTINCT <Filed name="">) en una consulta paginada?</Filed>
01-23-2025
11:29 PM
Source Community: Power BI | Source Author Name: sandipghosh2
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2025
05:26 PM
Source Community: Power BI | Source Author Name: v-stephen-msft

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
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Recommendations
Subject | Author | Posted | |
---|---|---|---|
02-19-2024 06:07 AM | |||
04-03-2020 07:49 AM | |||
04-15-2021 03:04 AM | |||
02-08-2023 12:31 AM | |||
11-06-2023 07:53 AM |
Top Solution Authors (Last Month)
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |