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

Columna calculada: datos del mes anterior con varios filtros

Tengo la siguiente tabla, donde los puntajes mensuales de la cuenta se desglosan por categoría e ID de cliente. Para cada ID y categoría, me gustaría obtener los datos del mes anterior como una columna calculada. Intenté crear esto como una medida, pero los totales de la matriz no son precisos, y me dijeron que crear esto como una columna calculada puede resolver mi problema. Cualquier ayuda es apreciada:

Tabla actual:

ID de clienteMesCategoríaPuntuación
100101-02-2022Seguridad.98
100101-02-2022Costar.84
100101-02-2022Otro

.70

100101-03-2022Seguridad.91
100101-03-2022Costar.92

Tabla deseada:

ID de clienteMesCategoríaPuntuaciónPuntuación del mes pasado
100101-02-2022Seguridad.98
100101-02-2022Costar.84
100101-02-2022Otro

.70

100101-03-2022Seguridad.91.98
100101-03-2022Costar.92.84

Luego calcularé el cambio de punto porcentual en cada puntaje.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@byr10112 ,

Por favor, cree una columna como la siguiente:-

Column =
VAR _lastmonth =
    IF ( MONTH ( 'Table (4)'[Month] ) = 1, 12, MONTH ( 'Table (4)'[Month] ) - 1 )
VAR _year =
    IF (
        MONTH ( 'Table (4)'[Month] ) = 1,
        YEAR ( 'Table (4)'[Month] ) - 1,
        YEAR ( 'Table (4)'[Month] )
    )
RETURN
    CALCULATE (
        MAX ( 'Table (4)'[Score] ),
        FILTER (
            ALL ( 'Table (4)' ),
            'Table (4)'[Customer ID] = EARLIER ( 'Table (4)'[Customer ID] )
                && 'Table (4)'[Category] = EARLIER ( [Category] )
                && MONTH ( 'Table (4)'[Month] ) = _lastmonth
                && YEAR ( 'Table (4)'[Month] ) = _year
        )
    )

Salida:-

Samarth_18_0-1649690626835.png

Gracias

Samarth

View solution in original post

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

@byr10112 ,

Por favor, cree una columna como la siguiente:-

Column =
VAR _lastmonth =
    IF ( MONTH ( 'Table (4)'[Month] ) = 1, 12, MONTH ( 'Table (4)'[Month] ) - 1 )
VAR _year =
    IF (
        MONTH ( 'Table (4)'[Month] ) = 1,
        YEAR ( 'Table (4)'[Month] ) - 1,
        YEAR ( 'Table (4)'[Month] )
    )
RETURN
    CALCULATE (
        MAX ( 'Table (4)'[Score] ),
        FILTER (
            ALL ( 'Table (4)' ),
            'Table (4)'[Customer ID] = EARLIER ( 'Table (4)'[Customer ID] )
                && 'Table (4)'[Category] = EARLIER ( [Category] )
                && MONTH ( 'Table (4)'[Month] ) = _lastmonth
                && YEAR ( 'Table (4)'[Month] ) = _year
        )
    )

Salida:-

Samarth_18_0-1649690626835.png

Gracias

Samarth

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.