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
MARMAXCHEROT
Frequent Visitor

Discriminar los null en un promedio ponderado

Buenas tardes a todos, estoy intentando ponderar valores de una tabla para diferentes atributos (proteina, humedad, grasa, etc...).

 

En la columna de Cantidad tengo valores en todas las fechas, sin embargo en las columnas de atributos tengo algunos valores "null".   

 

El problema que tengo es que el calculo ponderado le esta asignando valor "0" a estos valores nulos y me desvirtua el resultado final.

 

Como debo hacer para indicarle a la medida utilizada que cuando haya un valor nulo (null) no tenga en cuenta esa fila en el calculo?

 

Este es el código que estoy utilizando para hacer el promedio ponderado:

 

ACIDEZ (P) = DIVIDE(
                                SUMX(GIRASOL, GIRASOL[CANTIDAD]*GIRASOL[ACIDEZ])
,sum(GIRASOL[CANTIDAD]))

 

M, gracias!

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

See if filtering out blanks (nulls) helps:

ACIDEZ (P) =
CALCULATE (
    DIVIDE (
        SUMX ( GIRASOL, GIRASOL[CANTIDAD] * GIRASOL[ACIDEZ] ),
        SUM ( GIRASOL[CANTIDAD] )
    ),
    NOT ISBLANK ( GIRASOL[CANTIDAD] )
)

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @MARMAXCHEROT ;

II am very glad to hear that your problem has been solved.
Would you mind accept the helpful replies as solutions? Then we could close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MARMAXCHEROT
Frequent Visitor

Muchas gracias por sus respuestas, pude solucionarlo con las alternativas propuestas por ustedes.

 

Saludos!

v-yalanwu-msft
Community Support
Community Support

Hi, @MARMAXCHEROT ;

You could try it.

ACIDEZ (P) = DIVIDE( 
                 SUMX ( 'GIRASO', 'GIRASO'[CANTIDAD] *'GIRASO'[ACIDEZ] ), 
                   CALCULATE( SUM(GIRASO[CANTIDAD]),'GIRASO'[ACIDEZ]<>BLANK()))

The final output is shown below:

vyalanwumsft_0-1641271722237.png
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AlexisOlson
Super User
Super User

See if filtering out blanks (nulls) helps:

ACIDEZ (P) =
CALCULATE (
    DIVIDE (
        SUMX ( GIRASOL, GIRASOL[CANTIDAD] * GIRASOL[ACIDEZ] ),
        SUM ( GIRASOL[CANTIDAD] )
    ),
    NOT ISBLANK ( GIRASOL[CANTIDAD] )
)

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.