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
zctqslo
Regular Visitor

DATESYTD y desglose

Hola

Estoy tratando de calcular una suma corriente que se restablece al final de cada año (31 de diciembre) y se refleja correctamente al perforar a través de trimestres y meses. Digamos que tengo Tabla1 con dos columnas:

- Fecha

- Ingresos

Hasta ahora he intentado:

TRIAL1 = CALCULATE(SUM(Table1[Revenue]), FILTER(ALL(Table1), ISONORAFTER(Table1[Date], MAX(Table1[Date]), DESC)))

Esto refleja la investigación con precisión, pero no se restablece a partir de 0 en enero 1 de un nuevo año. En su lugar, sigue agregando.

Por lo tanto, he intentado lo siguiente, que restablece correctamente la suma cada año, pero cuando, la perforación hacia abajo, muestra el valor para el trimestre específico (o mes o día) sin agregar con precisión.

TRIAL2 = CALCULATE(SUM(Table1[Revenue]), DATESYTD(Table[Date]))

He intentado combinar los dos, pero sin mucho éxito, ¿sugerencias? ¡Gracias!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hola @zctqslo ,

Intente crear una medida como esta:

RunningTotal = CALCULATE(
SUM( table1[revenue] ),
FILTER(  ALL(Table1) ,
SUMX( FILTER( Table1, EARLIER( Table1[date] ) <= Table1[date] &&YEAR(table1[date])=YEAR(EARLIER(table1[date]))), table1[revenue] )
)
)

test_running_total.PNG

Muestra .pbix

Saludos
Liang
Si este post ayuda, por favor 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-lianl-msft
Community Support
Community Support

Hola @zctqslo ,

Intente crear una medida como esta:

RunningTotal = CALCULATE(
SUM( table1[revenue] ),
FILTER(  ALL(Table1) ,
SUMX( FILTER( Table1, EARLIER( Table1[date] ) <= Table1[date] &&YEAR(table1[date])=YEAR(EARLIER(table1[date]))), table1[revenue] )
)
)

test_running_total.PNG

Muestra .pbix

Saludos
Liang
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@zctqslo , Puede tener lo siguiente para YTD. Pero necesitas usar Calendar

YTD QTY = TOTALYTD(Sum('order'[Qty]),'Date'[Date])
LYTD QTY = TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year))
Previous Year = CALCULATE(SUM('order'[Qty]), PREVIOUSYEAR('Date'[Date]))

YTD QTY forced= 
var _max = today()
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','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),'Date'[Date]<=_max)

YTD QTY forced= 
var _max = maxx('order',[Order date])
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

LYTD QTY forced= 
var _max1 =maxx('order',[Order date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
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)

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

Para obtener lo mejor de la función de inteligencia de tiempo. Asegúrese de que tiene un calendario de fechas y se ha marcado como la fecha en la vista de modelo. Además, únase a él con la columna de fecha de su 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...


Aprecia tus Felicitaciones.

Greg_Deckler
Super User
Super User

Vea si mi Inteligencia del Tiempo el Camino Duro proporciona una manera diferente de lograr lo que usted está buscando.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.