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
romovaro
Responsive Resident
Responsive Resident

Weekday date difference with Filter Task

HI Power BI community

 

I have the table below:

 

 

CIDINSTANCE_NUMBERTASKTASK_ASSIGNED_ONTASK_STATUSTASK_COMPLETED_DATETASKACTUALPERFORMERPRODUCT_DESCRIPTIONCUID
10005431229280Partner Acknowledgement - 1225829 - 1000543FR0127-JAN-22 04.22.27.000000 AMClosed27-JAN-22 09.15.05.529000 AMJohn SmithCSL1000543FR01
10004021207201Partner Acknowledgement - 1204055 - 1000402GB0126-JAN-22 10.52.33.000000 PMClosed28-JAN-22 01.09.36.999000 PMJohn SmithCSL1000402GB01
102871244225Partner Acknowledgement - 1243686 - 38132226-JAN-22 05.34.20.000000 PMClosed27-JAN-22 04.19.14.126000 PMJohn SmithSL381322
10004211211610Partner Acknowledgement - 1207771 - 1000421AT0226-JAN-22 11.36.11.000000 AMClosed08-FEB-22 12.30.32.453000 PMJohn SmithCSL1000421AT02
10004211211609Partner Acknowledgement - 1207771 - 1000421AT0126-JAN-22 11.32.12.000000 AMClosed08-FEB-22 12.22.54.029000 PMJohn SmithCSL1000421AT01
10004211211625Partner Acknowledgement - 1207771 - 1000421LU0226-JAN-22 11.29.05.000000 AMClosed30-JAN-22 03.16.14.050000 PMJohn SmithCSL1000421LU02
10004211211624Partner Acknowledgement - 1207771 - 1000421LU0126-JAN-22 11.25.23.000000 AMClosed30-JAN-22 03.16.14.050000 PMJohn SmithCSL1000421LU01
10004211211639Partner Acknowledgement - 1207771 - 1000421CH0126-JAN-22 11.17.20.000000 AMClosed10-FEB-22 07.25.01.194000 AMJohn SmithCSL1000421CH01
10004211211593Partner Acknowledgement - 1207771 - 1000421BR0126-JAN-22 11.13.27.000000 AMClosed01-FEB-22 04.04.15.410000 PMJohn SmithCSL1000421BR01
10004211211640Partner Acknowledgement - 1207771 - 1000421TR0126-JAN-22 10.59.13.000000 AMReceived John SmithCSL1000421TR01
10004211211635Partner Acknowledgement - 1207771 - 1000421RU0126-JAN-22 10.55.54.000000 AMClosed10-FEB-22 12.48.44.431000 PMJohn SmithCSL1000421RU01
10004211211622IPM HandOff26-JAN-22 10.52.20.000000 AMClosed04-FEB-22 06.57.13.616000 AMJohn SmithCSL1000421KZ01
10004211211614Partner Acknowledgement - 1207771 - 1000421FI0126-JAN-22 10.46.13.000000 AMReceived John SmithCSL1000421FI01
113281240718Greenlight Checks26-JAN-22 10.43.12.000000 AMClosed27-JAN-22 10.54.27.766000 AMJohn SmithSL381319
113281240717Partner Acknowledgement - 1240496 - 38131826-JAN-22 10.42.31.000000 AMClosed27-JAN-22 10.54.27.810000 AMJohn SmithSL381318
125841247787Partner Acknowledgement - 1247808 - 38132926-JAN-22 09.00.36.000000 AMClosed26-JAN-22 09.11.35.502000 AMJohn SmithSL381329
3802781233207Partner Acknowledgement - 1230324 - 380278PH0126-JAN-22 08.57.02.000000 AMClosed02-FEB-22 10.13.09.703000 AMJohn SmithCSL380278PH01

 

I need to create some calculations:

 

I already have the diff in days but I am struggling to connect the formula with the task and get the diff only for the task 

 

1. To calculate DURATION of a task (how long it took to complete) : 

I need to select TASK = "Partner Acknowledgement" and Task_status = CLosed and calculate the diff in days between task completed and taks assigned (But ONLY COUNTING WEEKDAYS)

romovaro_0-1646149248025.png

 

2. To calculate AGEING of OPEN tasks (how long they have been pending) :

I need to select TASK = "Partner Acknowledgement" and Task_status = Received and calculate the diff in days between task completed and taks assigned (But ONLY COUNTING WEEKDAYS)

romovaro_1-1646149395133.png

3. To calculate Between Task1 and task 2 :

I need to select

TASK = Greenlight Checks" and Task_status = Closed

&

TASK = IPM HandOff and Task_status = Closed

and use the Task COmpleted Date column to see the average time between Greenlight & IPM handoff (where pre-engagment task closed by Pre team) (if possible Weekdays)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @romovaro,

You can try to add an if statement into the expression and use today function as the default value to replace the blank values:

Work Day =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            CALENDAR (
                Table[Start Date],
                IF ( Table[End Date] <> BLANK (), Table[End Date], TODAY () )
            ),
            "WorkDay", IF ( WEEKDAY ( [Date], 2 ) < 6, 1, 0 )
        ),
        [WorkDay] = 1
    )
)

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@romovaro ,

Example to get workday between two dates as measure or column

 

measure =

Work Day = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Min(Table[Start Date]),Max(Table[End Date])),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))

 

 

column

Work Day = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[Start Date],Table[End Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))

 

for open you can use today

 

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amitchandak,

 

Regarding the Column formula. Tried to add the formula in my table but it seems that some of my end dates are blank and I get the error that "The start Date or end date in calendar function can not be Blank Value". Something that can be fixed?

 

I tried the measure formula but it seems I get the total instead of the average. I don't see the option for the average.

 

romovaro_0-1646156713758.png

 

 

Anonymous
Not applicable

HI @romovaro,

You can try to add an if statement into the expression and use today function as the default value to replace the blank values:

Work Day =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            CALENDAR (
                Table[Start Date],
                IF ( Table[End Date] <> BLANK (), Table[End Date], TODAY () )
            ),
            "WorkDay", IF ( WEEKDAY ( [Date], 2 ) < 6, 1, 0 )
        ),
        [WorkDay] = 1
    )
)

Regards,

Xiaoxin Sheng

Hi Xiaoxin,

 

I have another question regarding comparing dates. In this case, my Date column is only one (completed Date Column)

 

Table is the same one as the first post.

3. To calculate Between Task1 and task 2 :

I need to select

TASK = Greenlight Checks" and Task_status = Closed and see the date in the Completed Date column

&

TASK = IPM HandOff and Task_status = Closed and see the date in the Task Completed Column.

 

Then I need to calculate the average days between both dates. 

 

In that case, the start date and End Date is the same column....

Work Day =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            CALENDAR (
                Table[Start Date],
                IF ( Table[End Date] <> BLANK (), Table[End Date], TODAY () )
            ),
            "WorkDay", IF ( WEEKDAY ( [Date], 2 ) < 6, 1, 0 )
        ),
        [WorkDay] = 1
    )
)

 

 

Thanks XiaoXin, it works 

 

I have another question regarding some formulas I used in another question. In case you have time to check.

 

https://community.powerbi.com/t5/Desktop/Review-Custom-formulas/m-p/2369505

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.