Forum Discussion

GCH_FR's avatar
GCH_FR
Icon for Helper I rankHelper I
1 year ago
Solved

SUMMARIZE WITH DATE AND OTHER CONDITONS

Hello everybody    I'm here to ask somme help :   I've got a table like that named "0-FUP" :  CODIFICATION BUDGET BPA LISSAGE BPA DATE BPA FORCEE DATE DEBUT ACTION BPA TEMPS THEORIQUE BP...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi GCH_FR 
    Thank you for reaching out microsoft fabric community forum.

    The cumulative calculation logic in your current setup may be producing incorrect results due to the use of the EARLIER function, which can create context-related issues when used in complex filters or nested row contexts. A more robust and reliable approach is to use the ALLEXCEPT function, which ensures that the cumulative sum is correctly calculated for each "CODIFICATION" by preserving its context while allowing the accumulation over time. For example, the DAX expression:

    CumulativeTimeBPA =
    CALCULATE (
        SUM ( [DailyTimeBPA] ),
        FILTER (
            ALLEXCEPT ( DailyTime, DailyTime[CODIFICATION] ),
            DailyTime[Date] <= EARLIER ( DailyTime[Date] )
        )
    )

    ensures that for each row, the sum includes all previous dates for the same "CODIFICATION" without being disrupted by unrelated filters. 


    If this solution helps, please consider giving us Kudos and accepting it as the solution so that it may assist other members in the community
    Thank you.