Forum Discussion
Suma de valores Acumulado Inversa
- 7 months ago
Hola,
Por favor revisa el tipo de dato de la columna de fecha. La lógica puede romperse si es DateTime o si es inconsistente entre las tablas de hechos.
Si ese es el caso, ¿podrías intentar convertir la columna a formato fecha y luego aplicar el cálculo:
Date_Format = DATE ( YEAR([Date]), MONTH([Date]), DAY([Date]) ) Reverse Cumulative := CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL( 'Table'[Date_Format] ), 'Table'[Date_Format] >= MAX( 'Table'[Date_Format] ) ) )Esto garantiza una comparación de fechas consistente y, a menudo, resuelve resultados en blanco o inesperados.
- 7 months ago
Hi gkarlo , Thank you for reaching out to the Microsoft Community Forum.
stoic-harsh ’s original DAX is correct, the problem you’re seeing comes from the date model, not the formula. When reverse cumulative totals return blanks or strange values, it almost always means the dates coming from your fact tables don’t line up cleanly with the calendar, for example they’re DateTime instead of Date or different tables use different date grains.
Make sure every fact table that contributes to this measure has a pure Date column (no time) and that all of them are related to the same master calendar on that Date. Then use that calendar date both in the visual and in the DAX. Once the dates are aligned at the same grain, the original reverse-cumulative pattern will work and you’ll get the expected November -> October -> September roll-up without changing the logic.
- 7 months ago
Hi gkarlo , hope you are doing great. May we know if your issue is solved or if you are still experiencing difficulties. Please share the details as it will help the community, especially others with similar issues.
Hola gkarlo,
He escrito este DAX:
CALCULATE (
SUM( 'Table'[Value] ),
FILTER (
ALL ( 'Table'[Date] ),
'Table'[Date] >= MAX( 'Table'[Date] )
)
)Aquí, MAX(Date) captura la fecha de la fila actual, ALL(Date) elimina el contexto de fila, y la condición Date>=fetcha actual obliga a DAX a sumar el período actual y todos los períodos posteriores, generando un acumulado descendente.
- gkarlo7 months ago
Helper I
hola,
muchas gracias por tu rápida respuesta.
Sin embargo, he probado usando la tabla de fechas maestra y resulta que no arroja ningun valor. También intenté usar las fechas de las tablas propias que se relacionan a la medida creada que es la suma de dos tablas diferentes. Dando como resultado valores erroneos y no deseados.
Me pregunto si existe otra manera de obtener este acumulado invertido?
Gracias de antemano
- stoic-harsh7 months ago
Super User
Hola,
Por favor revisa el tipo de dato de la columna de fecha. La lógica puede romperse si es DateTime o si es inconsistente entre las tablas de hechos.
Si ese es el caso, ¿podrías intentar convertir la columna a formato fecha y luego aplicar el cálculo:
Date_Format = DATE ( YEAR([Date]), MONTH([Date]), DAY([Date]) ) Reverse Cumulative := CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL( 'Table'[Date_Format] ), 'Table'[Date_Format] >= MAX( 'Table'[Date_Format] ) ) )Esto garantiza una comparación de fechas consistente y, a menudo, resuelve resultados en blanco o inesperados.