Reply
Syndicate_Admin
Administrator
Administrator
Syndicated - Inbound

Ayuda para marcar el cambio de estado

Source Community: Power BI | Source Author Name: ellywinters

Quiero tener una medida que muestre 1 cuando un estado haya cambiado y 0 cuando el estado sea el mismo que el valor de ayer. Mi conjunto de datos es bastante grande, por lo que quiero evitar usar una columna calculada si es posible.

Siento que estoy muy cerca de tener el DAX correcto, pero esta medida no me está dando el resultado que estoy buscando.

Change Status Flag = 
INT (
    COUNTROWS (
        FILTER (
            'Table',
            'Table'[Key]
                = EARLIER ( 'Table'[Key] )
                && 'Table'[Status]
                    <> EARLIER ( 'Table'[Status] )
                && 'Table'[Snapshot Date]
                    = EARLIER ( 'Table'[Snapshot Date] )
        )
    ) > 0
)

Lo que estoy recibiendo -
Valor establecido en 1 aunque el estado del día anterior no haya cambiado

ellywinters_0-1693008982149.png

Lo que quiero:

Marque solo las filas donde el estado es diferente al de ayer.

ellywinters_1-1693009029019.png

¿Alguien podría ayudarme con el DAX para lograr esto? Gracias de antemano por su ayuda.

Se adjuntan mis datos de muestra.

Snapshot DateKeyStatus
8/25/2023 0:00ManzanasEnviado
8/24/2023 0:00ManzanasEnviado
8/23/2023 0:00ManzanasEnviado
8/22/2023 0:00ManzanasEnviado
8/21/2023 0:00ManzanasEnviado
8/20/2023 0:00ManzanasEnviado
8/19/2023 0:00ManzanasEnviado
8/18/2023 0:00ManzanasEnviado
8/17/2023 0:00ManzanasOrdenado
8/25/2023 0:00NaranjasEnviado
8/24/2023 0:00NaranjasEnviado
8/23/2023 0:00NaranjasEnviado
8/22/2023 0:00NaranjasEnviado
8/21/2023 0:00NaranjasEnviado
8/20/2023 0:00NaranjasEnviado
8/19/2023 0:00NaranjasEnviado
8/18/2023 0:00NaranjasEnviado
8/17/2023 0:00NaranjasOrdenado
5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Source Community: Power BI | Source Author Name: ThxAlot
Syndicated - Inbound

Hasta ahora, pocos usuarios optan por las funciones de ventana; Tal vez pocos tienen una comprensión profunda de ellos.

Espero que las funciones de la ventana sean más eficientes en tales escenarios que FILTER() de la "vieja escuela".

ThxAlot_0-1693076840736.png

Syndicate_Admin
Administrator
Administrator

Source Community: Power BI | Source Author Name: Ashish_Mathur
Syndicated - Inbound

Hola

Se adjunta el archivo PBI.

Espero que esto ayude.

Ashish_Mathur_0-1693030062536.png

Syndicate_Admin
Administrator
Administrator

Source Community: Power BI | Source Author Name: foodd
Syndicated - Inbound

Tomo Kudos en cualquier momento. ¡Me alegro de poder ayudar!

Syndicate_Admin
Administrator
Administrator

Source Community: Power BI | Source Author Name: ellywinters
Syndicated - Inbound

Esto funciona brillantemente y es muy útil tenerlo en el arsenal. Muchas gracias @foodd , hiciste mi viernes por la noche!

Syndicate_Admin
Administrator
Administrator

Source Community: Power BI | Source Author Name: foodd
Syndicated - Inbound

Establezca la columna personalizada para que sea:

Change Status Flag = 
VAR CurrentDate = 'Table'[Snapshot Date]
VAR CurrentKey = 'Table'[Key]
VAR CurrentStatus = 'Table'[Status]
VAR PreviousStatus =
    CALCULATE(
        FIRSTNONBLANK('Table'[Status], 1),
        FILTER(
            'Table',
            'Table'[Snapshot Date] = CurrentDate - 1 &&
            'Table'[Key] = CurrentKey
        )
    )
RETURN IF(ISBLANK(PreviousStatus), 0, IF(CurrentStatus <> PreviousStatus, 1, 0))

foodd_0-1693013413420.png

avatar user

Helpful resources

Announcements
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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)