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

Ingresos YTD por el mismo período en años anteriores - DAX no funciona

Intento calcular los ingresos YTD para este año y para el mismo perioed en años anteriores, pero el DAX no parece estar funcionando como se esperaba.

Estas son las medidas calculadas que producen la tabla siguiente:

Ingresos: CALCULATE(sum('Transactions'[Amount] ),Transactions[Account Type]-"Revenue")
Ingresos YTD - TOTALYTD([Ingresos],'Calendario'[Fecha])
Ingresos LY YTD - CALCULATE([Ingresos YTD],SAMEPERIODLASTYEAR('Calendario'[Fecha]))
Los ingresos de LY YTD para 2019 deberían ser 163.492, pero en su lugar obtendré los ingresos para todo el año.

Capture.PNG

Cualquier ayuda sería apreciada, gracias!

1 ACCEPTED SOLUTION
byoung
Frequent Visitor

Pude usar el calendario definitivo para la solución, que se encuentra aquí:

https://www.youtube.com/watch?v=zXZAZrUwUe8

View solution in original post

4 REPLIES 4
byoung
Frequent Visitor

Pude usar el calendario definitivo para la solución, que se encuentra aquí:

https://www.youtube.com/watch?v=zXZAZrUwUe8

v-eqin-msft
Community Support
Community Support

Hola @byoung ,

Según mi entendimiento, usted quiere calcular YTD y el año pasadoYTD, ¿verdad?

Puede usar la siguiente fórmula:

YTD =
CALCULATE ( SUM ( 'Table'[Revenue] ), DATESYTD ( 'Table'[Date] ) )
YTD LY =
CALCULATE (
    SUM ( 'Table'[Revenue] ),
    DATEADD ( DATESYTD ( 'Table'[Date] ), -1, YEAR )
)

Sólo para 2020

Total 2020 =
CALCULATE (
    SUM ( 'Table'[Revenue] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date].[Year] = 2020 )
)
YTD 2020 =
IF (
    YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ) = 2020,
    CALCULATE ( SUM ( 'Table'[Revenue] ), DATESYTD ( 'Table'[Date] ) ),
    BLANK ()
)

Mi visualización tiene este aspecto:

8.31.4.1.PNG

¿Es el resultado lo que quieres? Si tiene alguna pregunta, cargue algunas muestras de datos y la salida esperada.

Por favor, enmascarar los datos confidenciales antes de cargar.

Saludos

Eyelyn Qin

@Eyelyn9 gracias por la respuesta! Si aún así sigues teniendo problemas, intentate con referencia.

https://we.tl/t-Ag2Wziw5sQ

Estoy filtrando por la empresa A, B o C y un prefijo de cuenta de 4 representa los ingresos. La compañía B es la mejor, ya que hay un largo historial de transacciones que abarca varios años.

¿Puedes echar un vistazo, por favor?

¡Gracias!

amitchandak
Super User
Super User

@byoung, intenta como

LYTD QTY forced= 
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

LYTD QTY forced= 
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),month('Date'[Date])<=month(_max) && day('Date'[Date])<=day(_max) )

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.