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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MARMAXCHEROT
Regular 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
Regular 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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