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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
reynaldo_malave
Helper III
Helper III

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 :

 

reynaldo_malave_0-1625601150994.png

 

Thanks in advance

2 REPLIES 2
Fowmy
Super User
Super User

@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
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

HI @Fowmy ,

Thanks for your answer, although new version aggregates shows a wrong total.

reynaldo_malave_0-1625603812341.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors