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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
babyjb1979
Helper I
Helper I

Calculation for consecutive work days for employee

Hi all,

 

I am creating a measure to calculate the consecutive work days for every employee. The table has columns including [Employee ID],[Work Date]

I extact an employee as test, I already make it using following DAX: (One employee's data as a new data source)

Consecutive Work Days =
var tb1=MAX('Date'[Date])
var tb2=ALL('Date'[Date])
var tb3=ALL('Work'[Work Date])
var tb4=EXCEPT(tb2,tb3)
var tb5=MAXX(FILTER(tb4,[Date]<=tb1),[Date])
Return
INT(tb1-tb5)
babyjb1979_0-1693327570564.png

Now, I want to apply the DAX to all employees:

Consecutive Work Days 1 =
CALCULATE(
var tb0=SUMMARIZE('Employee Transaction','Employee Transaction'[Work Date])
var tb1=MAX('Date'[Date])
var tb2=ALL('Date'[Date])
var tb3=EXCEPT(tb2,tb0)
var tb4=MAXX(FILTER(tb3,[Date]<=tb1),[Date])
Return
INT(tb1-tb4),
FILTER('Employee Transaction','Employee Transaction'[Employee Number]=EARLIER('Employee Transaction'[Employee Number]))
)
babyjb1979_1-1693327770893.png

I don't know what the reason leading to the error. Could you please help me out?

 

Thank you in advance!

Branko

2 REPLIES 2
technolog
Super User
Super User

I hope this message finds you well. I've noticed that this solution remain unresolved. If any of you have managed to find a resolution to the issue, I kindly request that you share your solution for the benefit of the entire community. Alternatively, if you're still facing challenges, please do let us know as well.

Your insights and updates will greatly assist others who might be encountering the same challenge.

babyjb1979
Helper I
Helper I

No one knows the solution?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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