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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors