Forum Discussion

scooby91's avatar
scooby91
New Member
8 years ago
Solved

Cumulative count with null values

Hello,   I'm trying to do a cumulative count based on dates, however, I am encountering problems with null values.   The code based on start dates is below, which produces the desired result:   ...
  • v-xjiin-msft's avatar
    8 years ago

    Hi scooby91,

     

    1. In your scenario, the Cumulative End should work. The issue is not related to the expression. It is because that the MonthYearNo is based on Start Date. If you create a new MonthYearNo based on End Date and put it with Cumulative End into another table. The result should be right. Please refer;

     

     

    2. For this scenario, you can try to calculate the Cumulative count based on slicer (Table 2) MonthYearNo not based on your source table (cumulative) MonthYearNo. 

     

    To achieve this, first we should convert MonthYearNo to number type:

    MonthYearNo = YEAR('Calendar'[Date])*100 + MONTH('Calendar'[Date] )

    Then try following measure:

     

    New Cumulative Start =
    CALCULATE (
        COUNTROWS (
            FILTER (
                ALL ( cumulative ),
                cumulative[MonthYearNo] <= MAX ( 'Table 2'[MonthYearNo] )
            )
        )
    )

    Then it will display the cumulative count for each month even the month doesn't have corresponding value in source table.

     

     

    Thanks,
    Xi Jin.