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
XaviOV
Helper V
Helper V

Datos del año actual frente al año pasado Línea y gráfico agrupado y gestionar la relación

Hola


Tengo un problema cuando necesito mostrar el valor del año actual y el año pasado (mismo período) en "Gráfico de líneas y columnas agrupadas", ahora tengo una tabla con la fecha en la que me relaciono con la tabla de valores que necesito calcular. El problema es que el valor del año pasado aparece de enero a diciembre.
El gráfico es la fecha relativa de este año.
Capturas de pantalla adjuntas.


saludos


Xavi

Anual actual vs anterior.png

Anual actual vs anterior1.png

Anual actual vs anterior2.png

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hola @XaviOV ,

¿Pruebas las fórmulas que sugiere Amitchandak? ¿Has resuelto este problema? En caso afirmativo, acepte la respuesta útil como solución. Y bienvenido scompartir sus propias soluciones. Aquí se beneficiará que más gente.

Si todavía necesita ayuda, comparta más detalles, como datos de muestra y resultados esperados. Lo entenderemos claramente.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@XaviOV ,

Trate como

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today()) //change end date of year

Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,year),'Date'[Date]<=date(year(today())-1,month(today()),day(today())))

o algo así

This Year =
var _max = maxx('Sales','Sales'[Date])
var _min = date(year(_max),1,1)

return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))

last Year =
var _max1 = maxx('Sales','Sales'[Date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
var _min = date(year(_max),1,1)

return
CALCULATE(SUM('Sales'[Sales]), FILTER(all('Date'), 'Date'[Date]<=_max && 'Date'[Date]>=_min))

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.