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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sagnik2402
New Member

DAX consecutive absent days flag

I have a table in power BI which contains Technician ID and date. There are 870 unique technician IDs and all the dates from 2021 tp 2023 for each ID. We have another column which says whether the technician was absent or present on a particular day. Whenever the technician was absent it is marked as "Gap" and whenever he was present, we say "No Gap". Help me identify the dates falling between long gaps of greater than or equal to 14 days for each technician using DAX. 

2 REPLIES 2
tamerj1
Super User
Super User

Hi @sagnik2402 
It is not easy without a sample data to work with therefore, not 100% surre but you may try the following two calculated columns solution

Absence Index =
VAR CurrentIDTable =
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Technician ID] ) )
VAR AbsenceTable =
    FILTER ( CurreIDTable, 'Table'[Status] = "Absent" )
VAR Rank1 =
    RANKX ( CurrentIDTable, 'Table'[Date],, ASC, DENSE )
VAR Rank2 =
    RANKX ( AbsenceTable, 'Table'[Date],, ASC, DENSE )
RETURN
    IF ( 'Table'[Status] = "Absent", Rank1 - Rank2 )
Flag > 14 Days =
IF (
    'Table'[Status] = "Absent",
    INT (
        COUNTROWS (
            CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Absence Index] ) )
        ) >= 14
    )
)
devanshi
Helper V
Helper V

LongGap =
VAR CurrentDate = Table[Date]
VAR PreviousDate = CALCULATE( MAX(Table[Date]), FILTER( ALLEXCEPT(Table, Table[Technician]), Table[Date] < CurrentDate ) )
VAR Gap = IF( ISBLANK(PreviousDate), BLANK(), DATEDIFF(PreviousDate, CurrentDate, DAY) )
RETURN
IF(Gap >= 14, "Gap", "No Gap")

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.