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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Mostrar YTDPrevious month y YTDtwoMonthsAgo

Hola Comunidad..!!

PatilPrasad027_1-1716807727508.png

Por favor, consulte la foto de arriba,

Estoy calculando YTD aquí,

1. Quiero mostrar el resultado de febrero a marzo y el resultado de marzo a abril y así sucesivamente.

2. Quiero mostrar el resultado de febrero a abril y el resultado de marzo a mayo y así sucesivamente.

He utilizado la siguiente lógica para calcular el mes actual hasta la fecha.

YTD_CurrentMonth = CALCULAR(SUMA(EDA_Trenline_Sales_Leo[ventas]),DATESYTD(res_month[MES 1]))
Por favor, ayúdame a llegar al resultado anterior.
Gracias
Prasad Patil
1 ACCEPTED SOLUTION

Gracias @rajendraongole1

Es correcto,

solo un ligero cambio en el cálculo según mi requisito,

Fueron current_date = MÁXIMO(res_month[MES 1])
Fueron shift_date = EOMONTH(current_date,-1)
Fueron resultado = CALCULAR([YTD_CurrentMonth],FECHASINPERÍODO(res_month[MES 1] ,shift_date,-1,MES))
DEVOLUCIÓN resultado
solo necesitas usar -1 instade de +1

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Hola @PatilPrasad027 ,

Puede usar OFFSET para obtener el YTD antes de la fila actual o antes de eso, pero la fórmula exacta variará según la dimensión en el objeto visual.

danextian_0-1716809562352.png

YTD sum = 
CALCULATE ( [Sales], DATESYTD ( d_Dates[Date] ) )
YTD LM = 
CALCULATE (
    [YTD sum],
    OFFSET (
        -1,
        ALLSELECTED ( d_Dates[Year], d_Dates[Month Short], d_Dates[Month Number] ),
        ORDERBY ( d_Dates[Month Number] )
    )
)
YTD 2LM = 
CALCULATE (
    [YTD sum],
    OFFSET (
        -2,
        ALLSELECTED ( d_Dates[Year], d_Dates[Month Short], d_Dates[Month Number] ),
        ORDERBY ( d_Dates[Month Number] )
    )
)

Por favor, vea el ejemplo de pbix adjunto.

Gracias @danextian

Tu solución también funciona..!!

Syndicate_Admin
Administrator
Administrator

Hola @PatilPrasad027 , ¿puedes probar con la siguiente lógica?

Datos reales desplazados hasta la fecha =
VAR CurrentDate = MAX('Date'[Date])
VAR ShiftedDate = EOMONTH(CurrentDate, -1)
DEVOLUCIÓN
CALCULAR(
[Datos reales hasta la fecha],
DATESINPERIOD('Fecha'[Fecha], FechaDesplazada, MES, 1)
)

funciona por mes, en lugar de mes, reemplace por Año y verifique.

Si esta publicación Ayuda, entonces por favor considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.

Gracias @rajendraongole1

Es correcto,

solo un ligero cambio en el cálculo según mi requisito,

Fueron current_date = MÁXIMO(res_month[MES 1])
Fueron shift_date = EOMONTH(current_date,-1)
Fueron resultado = CALCULAR([YTD_CurrentMonth],FECHASINPERÍODO(res_month[MES 1] ,shift_date,-1,MES))
DEVOLUCIÓN resultado
solo necesitas usar -1 instade de +1

¡Bien! @PatilPrasad027

Si esta publicación Ayuda, entonces por favor considere Acéptalo como la solución o dar un saludo

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors