Forum Discussion

gkarlo's avatar
gkarlo
Icon for Helper I rankHelper I
7 months ago
Solved

Suma de valores Acumulado Inversa

Buenos dias, Tengo un problema con calcular los valores acumulados de manera descendente respecto a la fecha, la medida deseada debe tener la siguiente logica: - El ultimo mes (ultima fecha) debe m...
  • stoic-harsh's avatar
    stoic-harsh
    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.

  • v-hashadapu's avatar
    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.

  • v-hashadapu's avatar
    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.