Forum Discussion

dstanisljevic's avatar
6 years ago
Solved

Running Count per Day

Hello,   I'm trying to a take the following table and create a very specific measure:   ID Status LastUpdate 1 Solved 03/15/2019 2 Open 05/14/2020 3 Open 01/12/2020 4 Solv...
  • v-zhenbw-msft's avatar
    6 years ago

    Hi dstanisljevic ,

     

    We can use the following steps to meet your requirement.

     

    1. Create a date table and there is no relationship between date table and table.

     

    Date = CALENDAR("2019/1/1","2020/12/31")    

     

     

    2. Create a measure to calculate the count.

     

    Measure = 
    VAR date_ =
        MIN ( 'Date'[Date] )
    VAR x =
        MAX ( 'Date'[Date] )
    RETURN
        IF (
            x < MAX ( 'Table'[LastUpdate] ),
            DISTINCTCOUNT ( 'Table'[ID] )
                - CALCULATE (
                    DISTINCTCOUNT ( 'Table'[ID] ),
                    FILTER ( 'Table', 'Table'[Status] = "Solved" && 'Table'[LastUpdate] < date_ )
                ),
            CALCULATE (
                DISTINCTCOUNT ( 'Table'[ID] ),
                FILTER ( 'Table', 'Table'[Status] = "Solved" && 'Table'[LastUpdate] = date_ )
            )
    )

     

    3. Then create a table visual, put the date[date] and [Measure] to values, and add a slicer based on date[date].

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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