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
matus_jun
Frequent Visitor

Count Consecutive from Work day

matus_jun_0-1736937516446.png

Hi how can I count Consecutive workday from workday as you can see 1 , 2 , 5  , 6 , 7 , 8 from column Workday.
Consecutive workday should be 1,2 , 1,2,3,4 
thank you for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @matus_jun ,

 

Here is my test for your reference.

Consecutive workday = 
VAR _minweek = WEEKNUM(MINX(ALL('WorkdayCalendar'[Date]),'WorkdayCalendar'[Date]),2)
VAR _interval = DATEDIFF(MINX(ALL('WorkdayCalendar'[Date]),'WorkdayCalendar'[Date]),MAX('WorkdayCalendar'[Date]),DAY)+1
VAR _weekday = WEEKDAY(MAX('WorkdayCalendar'[Date]),1)
RETURN
IF(WEEKNUM(MAX('WorkdayCalendar'[Date]),1)=_minweek,_interval,_weekday)

vmengmlimsft_1-1737108686458.png

 

 

 

 

Best regards,

Mengmeng Li

 

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @matus_jun ,

 

Here is my test for your reference.

Consecutive workday = 
VAR _minweek = WEEKNUM(MINX(ALL('WorkdayCalendar'[Date]),'WorkdayCalendar'[Date]),2)
VAR _interval = DATEDIFF(MINX(ALL('WorkdayCalendar'[Date]),'WorkdayCalendar'[Date]),MAX('WorkdayCalendar'[Date]),DAY)+1
VAR _weekday = WEEKDAY(MAX('WorkdayCalendar'[Date]),1)
RETURN
IF(WEEKNUM(MAX('WorkdayCalendar'[Date]),1)=_minweek,_interval,_weekday)

vmengmlimsft_1-1737108686458.png

 

 

 

 

Best regards,

Mengmeng Li

 

 

 

johnt75
Super User
Super User

Make sure that you have a date table, then you can use

 

Consecutive workdays =
VAR ReferenceDate =
    MAX ( 'Date'[Date] )
VAR AllDates =
    ALL ( 'Date'[Date] )
VAR WorkDays =
    CALCULATETABLE ( VALUES ( 'Table'[Workday] ), ALLSELECTED () )
VAR NonWorkDays =
    EXCEPT ( AllDates, WorkDays )
VAR PreviousNonWorkDay =
    MAXX ( FILTER ( NonWorkDays, 'Date'[Date] <= ReferenceDate ), 'Date'[Date] )
VAR Result =
    INT ( ReferenceDate - PreviousNonWorkDay )
RETURN
    Result

 

How can i have date table that I can use with workday I create one but result I got is all 0

Make sure that there is no relationship between date and the workday column, Power BI can create relationships automatically. All you need the date table for in this case is to generate a list of dates which are not work days, for that you need a full calendar.

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 community update carousel

Fabric Community Update - June 2025

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