Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
YogeshS
Frequent Visitor

calculating the consecutive count

Hello,

 

YogeshS_0-1685959586880.png

I am trying to calculate the consecutive absent count of students......like they should be absent for 7 days continuously then the dax should take the count as 1 and if another student is asbsent for continuous 7 days then, dax should increase its count to 2. I have attached the above picture for reference. Consider Dates are stacked in one single column,  in the above picture i divided the date into columns for easy understanding.
Help me to create a measure/ calculated column.

3 REPLIES 3
YogeshS
Frequent Visitor
YogeshS
Frequent Visitor

Hi @v-jianboli-msft ,

Thank you for your help,
But my data seems to be big, i am getting the below error after implementing your measure.

YogeshS_1-1686297913104.png

Could you please help me with this?

v-jianboli-msft
Community Support
Community Support

Hi @YogeshS ,

 

Please try:

Measure =
VAR _a =
    COUNTX ( FILTER ( 'Table', [Value] = 0 ), [Date] )
VAR _b =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        FILTER (
            FILTER ( ALL ( 'Table' ), [ID] <= MAX ( 'Table'[ID] ) ),
            COUNTX (
                FILTER ( ALL ( 'Table' ), [ID] = EARLIER ( 'Table'[ID] ) && [Value] = 0 ),
                [Date]
            ) = 7
        )
    )
RETURN
    IF ( _a = 7, _b )

Final output:

vjianbolimsft_0-1686105327258.png

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.