Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Finding Consecutive number and counting

Hi,

 

I have attached data set and expected output as well, but not sure how to get the perfect DAX to find the consecutive number and counting.

 

Pls refer the below and let me know how is this feasible.

 

Sr NoDateNameStatus
11/11/2022ABCPresent
22/11/2022ABCPresent
33/11/2022ABCAbsent
44/11/2022ABCAbsent
55/11/2022ABCAbsent
65/12/2022ABCAbsent
75/13/2022ABCPresent
85/14/2022ABCAbsent
95/15/2022ABCAbsent
101/11/2022DEFPresent
112/11/2022DEFAbsent
123/11/2022DEFAbsent
134/11/2022DEFPresent
145/11/2022DEFPresent
155/12/2022DEFAbsent
165/13/2022DEFAbsent
175/14/2022DEFPresent
185/15/2022DEFPresent

 

NameConsecutive Absent 2Consecutive Absent 3Consecutive Absent 3 plus
ABC101
DEF200

Thanks,

2 Replies

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi Anonymous ,

     

    Do you want to count the number of consecutive absences or the length of each absence, grouped by name? Would the following formula be helpful to you.

    a =
    VAR next_ =
        TOPN (
            1,
            FILTER (
                'Table',
                'Table'[Sr No] < EARLIER ( 'Table'[Sr No] )
                    && 'Table'[Name] = EARLIER ( 'Table'[Name] )
            ),
            [Sr No], DESC
        )
    VAR next_status =
        MINX ( next_, [Status] )
    RETURN
        IF ( 'Table'[Status] = "Absent" && 'Table'[Status] = next_status, "yes", "no" )


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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

  • Anonymous's avatar
    Anonymous
    Not applicable

    I want to see consecutive count of number of absent like total number of absent by student absent continiously 2 times, 3 times and 3 plus times. so that I can focus on the student who are absent frequently continiously.

     

    Ex: ABC is continiously absent 4 times from March 11 to May 12. Absent 2 times from May 14th May 15

             3 plus   2 times

    ABC      1          1

    DEF       0          2

     

    Any solution pls.