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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Syndicate_Admin
Administrator
Administrator

Declaración IF Two Measure Wrong Grand Total (transferimos el enlace de muestra)

Hola

En mi ejemplo, mi medida no se ejecuta

quiero mostrar: si TotalProduct es null el TotalBudget else TotalProduct en la fila está bien, pero en el gran total es KO

https://we.tl/t-gaphp8NYUQ

Muchas gracias

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Estimado @MFelix gracias por su ayuda

Syndicate_Admin
Administrator
Administrator

@EdouSav ,

Esto está relacionado con el contexto cuando agrega más valores a su tabla luego el cambio de contexto en este caso el producto agrega un nivel de granularidad que cambia los valores, porque en el mes de octubre cuando tiene valores no obtiene el 200 para 68100.

Pruebe la siguiente medida:

IfNotSaleThenBudget2 = 

   var SalesTable = SUMMARIZE (
        sales,
        'product'[product],
        'Calendar'[Year],
        'Calendar'[Month Number],
       "TotalValue", [IfNotSalesThenBudget], "IDColumn", 
        'product'[product]&        'Calendar'[Year]&
        'Calendar'[Month Number]
    )
    
    var FilterSalesValues =  SELECTCOLUMNS(SalesTable, "FilterID", [IDColumn])
    
    
return   
  SUMX(  union(
    
    filter (SUMMARIZE (
        budget,
        'product'[product],
        'Calendar'[Year],
        'Calendar'[Month Number],
        "TotalValue", [IfNotSalesThenBudget], "IDColumn", 
        'product'[product]&        'Calendar'[Year]&
        'Calendar'[Month Number]
    ), NOT([IDColumn] in FilterSalesValues))
    
    
,SalesTable), [TotalValue])
 

Resultado a continuación y en archivo adjunto:

MFelix_0-1686172076452.png

Syndicate_Admin
Administrator
Administrator

Hola @MFelix

Gracias por su respuesta

pero tu medida no funciona con mi modelo, creo un PBIX de noticias para simular el error

la matriz calcula 317K pero el número real es 318 K

https://we.tl/t-ec1MT7SUjL

Si tienes otra idea

Muchas gracias

Syndicate_Admin
Administrator
Administrator

@EdouSav ,

Esto está relacionado con la transición de contexto cuando se está haciendo la comparación ya que la línea total el valor para el 42.802 por lo que su suma hasta el mismo valor tiene en la otra columna se debe hacer la siguiente medida:

IfNotSalesThenBudget = SUMX(VALUES('Calendar'[Month]),if([TotalProduct]=0,[TotalBudget],[TotalProduct]))

MFelix_0-1686000485494.png

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.