Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Calculate consecutive decreases over time?

Hi, hopefully someone can help with this? I have a table that looks like the below

Client_IDYearMonthTickets_Created
10442019Jul92
10442019Aug65
10442019Sep33
10442019Oct12
10442019Nov10
10442019Dec2

What I want to do is analyze Client_IDs who have a consecutive Tickets_Created on a month by month basis.  To do this I created a calculated column which compared the current month to the previous month

Client_IDYearMonthTickets_CreatedDifference
10442019Jul92-2
10442019Aug65-27
10442019Sep33-32
10442019Oct12-20
10442019Nov10-2
10442019Dec2-8

Now what I want is using the above, get a table that shows the top ten Client_IDs that have the most consecutive months decrease in tickets. So for example, the above Client_ID would have a consecutive decrease of 6 months. If the same Client_ID had an increase this month (compared to November) then they would no longer show on the top 10 table as this would reset the conescutive months they have decreased.

I hope this makes sense? Appreciate any help

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

    I have spend some time together with experts using some random sample. We found that you can make the consecutive count, but the tricky part is you have to re-count each time when there is increase in the tickets.

    I am afraid that DAX do not support this kind of calculation, maybe try with power query.

    This is my consecutive count formula if needed: 

     

    Count concecutive decrease =
    IF (
        [Differece] < 0,
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[Client_ID] ), [Differece] < 0 ),
            'Table'[Month] <= EARLIER ( 'Table'[Month] )
        ) + 0,
        BLANK ()
    )

     


    Best
    Paul