Forum Discussion

reynaldo_malave's avatar
reynaldo_malave
Helper III
5 years ago

Sumx column total

Hi Guys, 

 

I am trying to move a calculation from a sql query to dax. I am able to calculate the number on a row level but i cannot get a total from it.
Here is my Dax: 

Costo Oportunidad = 

var precioventa =

    LOOKUPVALUE(
        Productos[Precio Venta],
        Productos[Código Producto],
        SELECTEDVALUE(
            Desabasto[Producto]
        )
    )

var ventateorica7dias =

    SUMX(
        Desabasto,
        (DIVIDE(
            CALCULATE( SUM( Desabasto[Vtas30Días] ) ),
            30
        ) - Desabasto[Existencias]) * precioventa      
    )

return 

    ventateorica7dias

 

Notice how the left column has a total and the right does not :

 

 

Thanks in advance

2 Replies

  • reynaldo_malave 

    Can you try this modified version?

    Costo Oportunidad =
    VAR ventateorica7dias =
        SUMX (
            Desabasto,
            ( DIVIDE ( SUM ( Desabasto[Vtas30Días] ), 30 ) - Desabasto[Existencias] )
                * LOOKUPVALUE (
                    Productos[Precio Venta],
                    Productos[Código Producto], Desabasto[Producto]
                )
        )
    RETURN
        ventateorica7dias