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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Valor anterior misma columna

Hola Comunidad,

Me podrían ayudar con la función dax para calcular a partir de un valor anterior de la misma columna, para sumar o restar dicho valor las columnas adyacentes: Faltante al Plan y Surtido de mas al plan.

Ejemplo de excel:

nancyelizondo_0-1597351400162.png

Para calcular el Faltante acumulado por día, debo tomar en cuenta el valor del resultado del día anterior, para validar si fue mayor a cero y como resultado de esa validación, restar el faltante al plan - surtido de mas al plan, si no es mayor a cero entonces deberá sumar el valor anterior + faltante al plan + surtido de mas al plan.

¿Cómo lo hago en dax?

 

Gracias por la ayuda!!

Saludos.

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi  @Anonymous ,

According to my understanding, you want to calculate the sum based on previous row, right?

You could use the following formula after adding anIndex columnin Query Editor :

 

// create a new column

 

HMinusI =
'Previous' [H] - 'Previous' [I]

 

// Calculate sum

accumulated =
VAR a =
    CALCULATE (
        MAX ( Previous[Index] ),
        FILTER ( ALL ( Previous ), [HMinusI] < 0 && [Index] <= MAX ( Previous[Index] ) )
    )
RETURN
    IF (
        ISBLANK ( a ),
        MAX ( Previous[HMinusI] ),
        CALCULATE (
            SUM ( Previous[HMinusI] ),
            FILTER ( ALL ( Previous ), [Index] >= a && [Index] <= MAX ( Previous[Index] ) )
        )
    )

My visualization looks like this:

8.17.3.PNG

Is the result what you want? If not, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best regards,

Eyelyn Qin

 

View solution in original post

3 REPLIES 3
wfigueroa
New Member

Equipo, por favor su ayuda con este ejercicio

 

Tengo mi inventario al cierre de la seman 48 que es 2594 y quiero proyectarlo en las siguientes semanas sumnado la acumulación de paletas, 

 

cómo haria para que en los espacios en blanco aparesca el resultado de lo escrito a mano alzada.

 

wfigueroa_0-1639067458538.png

 

Muchas gracias comunidad

Sldos

v-eqin-msft
Community Support
Community Support

Hi  @Anonymous ,

According to my understanding, you want to calculate the sum based on previous row, right?

You could use the following formula after adding anIndex columnin Query Editor :

 

// create a new column

 

HMinusI =
'Previous' [H] - 'Previous' [I]

 

// Calculate sum

accumulated =
VAR a =
    CALCULATE (
        MAX ( Previous[Index] ),
        FILTER ( ALL ( Previous ), [HMinusI] < 0 && [Index] <= MAX ( Previous[Index] ) )
    )
RETURN
    IF (
        ISBLANK ( a ),
        MAX ( Previous[HMinusI] ),
        CALCULATE (
            SUM ( Previous[HMinusI] ),
            FILTER ( ALL ( Previous ), [Index] >= a && [Index] <= MAX ( Previous[Index] ) )
        )
    )

My visualization looks like this:

8.17.3.PNG

Is the result what you want? If not, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best regards,

Eyelyn Qin

 

lbendlin
Super User
Super User

You create a calculated measure that captures the current day value, and then filters all values by the largest day that is smaller than your current day. That way you get access to the "previous"  "row". (it's not actually a row, more a context)

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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