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
Syndicate_Admin
Administrator
Administrator

Ayuda de Dax

Hola, experto en power bi.

Necesita ayuda para calcular una columna para 5 banderas diferentes como se muestra a continuación.

Tengo una columna de rango de fechas desde el año1960 hasta el año 2030 y a partir de ella quiero calcular una columna que tendrá 5 falgs para 1-mes actual,2-mes anterior,3-anterior-1 y 4- año pasado y el 5- No.

Donde actual será el mes actual y luego anterior-1, anterior -2 y anterior -3 y el resto será NO.

Supongamos que esto es febrero de 2023, por lo que la bandera actual será febrero, la anterior será enero de 2023, la anterior -1 será diciembre de 2022 y el año pasado será noviembre de 2022 y el resto debería ser no.

Por favor, ayúdame a calcular esto usando dax.l

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

@Avinash_007 No estoy seguro de estar 100% en los requisitos, pero prueba esto. PBIX se adjunta debajo de la firma.

Column = 
    VAR __Date = [Date]
    VAR __Today = TODAY()
    VAR __CurrentEOM = EOMONTH(__Today,0)
    VAR __CurrentBOM = DATE(YEAR(__CurrentEOM),MONTH(__CurrentEOM),1)
    VAR __PreviousEOM = EOMONTH(__Today,-1)
    VAR __PreviousBOM = DATE(YEAR(__PreviousEOM),MONTH(__PreviousEOM),1)
    VAR __PreviousEOM1 = EOMONTH(__Today,-2)
    VAR __PreviousBOM1 = DATE(YEAR(__PreviousEOM1),MONTH(__PreviousEOM1),1)
    VAR __PreviousEOM2 = EOMONTH(__Today,-3)
    VAR __PreviousBOM2 = DATE(YEAR(__PreviousEOM2),MONTH(__PreviousEOM2),1)
    VAR __Result = 
        SWITCH(TRUE(),
            __Date <= __CurrentEOM && __Date >= __CurrentBOM,"Current Month",
            __Date <= __PreviousEOM && __Date >= __PreviousBOM,"Previous Month",
            __Date <= __PreviousEOM1 && __Date >= __PreviousBOM1,"Previous Month -1",
            __Date <= __PreviousEOM2 && __Date >= __PreviousBOM2,"Previous Month -2",
            "NO"
        )
RETURN
    __Result

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.