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
CEllinger
Helper I
Helper I

¿Combinar dos columnas con el mismo intervalo de fechas pero años diferentes?

Tengo una tabla que es Ventas por fecha. Se ve así:

Día n.o del añoFechaMesañoCompradorÓrdenes
11/1/201912019Dan1
21/2/201912019Dan2
31/3/201912019Dan3
11/1/202012020Dan4
21/2/202012020Dan5
31/3/202012020

Mis medidas son:

2019 Totales - Calcular(Sum(Ventas[Pedido]),Ventas[Año]-2019

2020 Totales á Calcular(Sum(Ventas[Pedido]),Ventas[Año]-2020

Cuando planeo estas medidas obtengo los valores distribuidos correctamente.

Sin embargo, 2020 (obviamente) faltan entradas de fecha. Quiero tomar el 2019 Total para cada día y aplicarlo a las fechas que faltan en 2020. Usando mi ejemplo anterior, los datos tendrían este aspecto:

Día n.o del añoFechaMesañoCompradorÓrdenes
11/1/201912019Dan1
21/2/201912019Dan2
31/3/201912019Dan3
11/1/202012020Dan4
21/2/202012020Dan5
31/3/202012020Dan 3

¿Cómo puedo quitar el año de mis cálculos para que esto funcione?

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hola @CEllinger

Cuando importe datos a Power BI por primera vez, agregue una columna de índice y, a continuación, cree columnas calcualadas como se muestra a continuación:

Capture2.JPG

Purchaser2 =
IF (
    [Purchaser]
        = BLANK (),
    CALCULATE (
        MAX ( 'Table'[Purchaser] ),
        FILTER (
            'Table',
            'Table'[Index]
                = EARLIER ( 'Table'[Index] ) - 1
        )
    ),
    [Purchaser]
)

orders2 =
IF (
    [Orders]
        = BLANK (),
    CALCULATE (
        MAX ( 'Table'[Orders] ),
        FILTER (
            'Table',
            'Table'[Month]
                = EARLIER ( 'Table'[Month] )
                && 'Table'[Day]
                    = EARLIER ( 'Table'[Day] )
                && 'Table'[Year]
                    = EARLIER ( 'Table'[Year] ) - 1
        )
    ),
    [Orders]
)


Saludos
Maggie
Equipo de Apoyo Comunitario _ Maggie Li
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

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.