Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.