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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Identify if entry/record is part of 'streak' longer than x days

I have a table holding data regarding absence. To simplify the table holds these columns:

 

employee no (integer)
absence code (integer)
starting date (date)
ending date (date)

 

The data going into this table is not necessarily for the whole period, but could be subsets, i.e. May 1 - May 5 and then again May 8 - May 12 (typically excluding weekend days).

 

Would like to know if any entry is part of a streak that is >= 30 days to identify short term or long term absence. This based on combination of employee and absence code.

 

Ultimately I need to be able to slice, so I can filter and make measures based on short/term to calculate how much in percent points the short term and long term make up.

 

As I see it there could be 2 approaches:

 

1) In PowerQuery try and group the start and end dates. Thinking I could offset Friday to Sunday to include the weekend days. Not sure how to join the periods though.

 

2) Or this could be done in DAX? Could this be accomplished through a calculated column?

 

Any advice on how to achieve this? Thanks in advance.

1 REPLY 1
tamerj1
Super User
Super User

Hi @Anonymous 

For a DAX calculated column please try

Absence Type =
VAR T =
CALCULATETABLE (
'Table',
ALLEXCEPT ( 'Table', 'Table'[Employee No], 'Table'[Absence Code] )
)
VAR StartDate =
MINX ( T, 'Table'[Starting Date] )
VAR EndDate1 =
MAXX ( T, 'Table'[Ending Date] )
VAR EndDate2 =
SWITCH ( WEEKDAY ( EndDate1, 2 ), 5, EndDate1 + 2, 6, EndDate1 + 1, EndDate1 )
VAR AbsenceDuration =
DATEDIFF ( StartDate, EndDate2, DAY )
RETURN
IF ( AbsenceDuration >= 30, "Long Term", "Short Term" )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.