Forum Discussion

djkoenig's avatar
djkoenig
Helper II
1 year ago
Solved

Improper Aggregation based on Slicer Selection (Descending Cumulative Total)

Hello Experts, I'm quite confused. I have calculated a descending running total like so:     DescendingCumulativeSum = VAR MaxDate = MAX('Patent List'[Earliest Priority Date]) VAR TotalCount ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi djkoenig 

     

    The problem with aggregating the DescendingCumulativeSum measure in the matrix after applying the slicer is due to the ALL() function used in DAX removing all the filters from the data table 'Patent List', please use the ALLSELECTED() function instead to preserve the effect of the external filters.

     

    DescendingCumulativeSum = 
    VAR MaxDate = MAX('Patent List'[Earliest Priority Date])
    VAR ExpiredCount = CALCULATE(COUNT('Patent List'[ID]), 'Patent List'[Dead or Alive] = "DEAD")
    VAR TotalCount = COUNTROWS(
        FILTER(
            ALLSELECTED('Patent List'),
            'Patent List'[Dead or Alive] = "DEAD"
        )
    )
    VAR CurrentCount = CALCULATE(
        COUNTROWS('Patent List'),
        FILTER(
            ALLSELECTED('Patent List'),
            'Patent List'[Earliest Priority Date] <= MaxDate &&
            'Patent List'[Dead or Alive] = "DEAD"
        )
    )
    RETURN
    TotalCount - CurrentCount + ExpiredCount

     

     

     

     

    Best Regards,
    Jarvis Tang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.