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
IslamAmer
Frequent Visitor

Cómo obtener el último valor Entrar en el mes anterior

Hola a todos

Tengo Table contiene una lectura de gague vlaues de agua para calcular la necesidad de consumo de restar el último valor en el mes actual con el último valor en el mes anterior

Obtengo el primero, pero no pude obtener el otro "último valor en el mes anterior"

Consumo de 5 - 2 x 3

ValorFecha
11-7-2020
230-7-2020
31-8-2020
54-8-2020

Gracias 🙂

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

Hola @IslamAmer

Construyo una mesa como la tuya para hacerme una prueba. Y agredo una columna Mes.

Month = MONTH('Table'[Date])

Mesa:

1.png

Entonces construyo una medida para lograr tu objetivo.

Measure 2 =

VAR _a =

    CALCULATE (

        SUM ( 'Table'[value] ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Date]

                = MAXX (

                    FILTER ( ALL ( 'Table' ), 'Table'[Month] = SUM ( 'Table'[Month] ) ),

                    'Table'[Date]

                )

                && 'Table'[Month] = SUM ( 'Table'[Month] )

        )

    )

VAR _b =

    CALCULATE (

        SUM ( 'Table'[value] ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Date]

                = MAXX (

                    FILTER ( ALL ( 'Table' ), 'Table'[Month] = SUM ( 'Table'[Month] ) - 1 ),

                    'Table'[Date]

                )

                && 'Table'[Month]

                    = SUM ( 'Table'[Month] ) - 1

        )

    )

RETURN

    _a - _b

Resultado:

2.png

Puede descargar el archivo pbix desde este enlace: Cómo obtener el último valor Enter en el mes anterior

Saludos

Rico Zhou

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hola @IslamAmer

Construyo una mesa como la tuya para hacerme una prueba. Y agredo una columna Mes.

Month = MONTH('Table'[Date])

Mesa:

1.png

Entonces construyo una medida para lograr tu objetivo.

Measure 2 =

VAR _a =

    CALCULATE (

        SUM ( 'Table'[value] ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Date]

                = MAXX (

                    FILTER ( ALL ( 'Table' ), 'Table'[Month] = SUM ( 'Table'[Month] ) ),

                    'Table'[Date]

                )

                && 'Table'[Month] = SUM ( 'Table'[Month] )

        )

    )

VAR _b =

    CALCULATE (

        SUM ( 'Table'[value] ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Date]

                = MAXX (

                    FILTER ( ALL ( 'Table' ), 'Table'[Month] = SUM ( 'Table'[Month] ) - 1 ),

                    'Table'[Date]

                )

                && 'Table'[Month]

                    = SUM ( 'Table'[Month] ) - 1

        )

    )

RETURN

    _a - _b

Resultado:

2.png

Puede descargar el archivo pbix desde este enlace: Cómo obtener el último valor Enter en el mes anterior

Saludos

Rico Zhou

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@IslamAmer, pruebe con una tabla de fechas unida a la fecha de su tabla

Este mes: CALCULATE(lastnonblankvalue(Table[Date],max(Table[value])),DATESMTD('Date'[Date]))
Last month ? CALCULATE(astnonblankvalue(Table[Date],max(Table[value])),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

Para obtener lo mejor de la función de inteligencia del tiempo. Asegúrese de que tiene un calendario de fechas y que se ha marcado como la fecha en la vista de modelo. Además, únase a ella con la columna de fecha de su/s hecho/s. Consulte:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Vea si mi seminario web sobre Time Intelligence puede ayudar: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Apreciamos tus Felicitaciones.

Hola

Su aspecto tiene algunos errores

IslamAmer_0-1596532905803.png

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.

Top Solution Authors