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

Difference between two dates with excluding weekends.

Dear Team,

Please help me solve for construct below query.

IDStatusStart DateEnd DateNo: of Days
201Done10/03/202210/06/20223
205Approved10/04/2022 9(when end date is blank we need to consider Today()-Start Date.)
206Deployed10/04/2022 9(when end date is blank we need to consider Today()-Start Date.)
207Done09/26/202209/29/20223

 

Please guide me how to write DAX fuction for above query.

 

Advance Thanks,

Venkata.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @VenkataRavi ,

Assum that there is one date dimension table in your model, you can create a calculated column as below to get the number of days between two dates. Please find the details in the attachment.

No.of Days =
VAR _enddate =
    IF ( ISBLANK ( 'Table'[End Date] ), TODAY (), 'Table'[End Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Date' ),
        DATESBETWEEN ( 'Date'[Date], 'Table'[Start Date], _enddate ),
        FILTER ( 'Date', WEEKDAY ( 'Date'[Date], 2 ) < 6 )
    )

yingyinr_0-1665970301166.png

In addition, you can refer the following blog to get it by DAX or Power Query method...

Calculate Workdays Between Two Dates In Power BI

yingyinr_1-1665970540703.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @VenkataRavi ,

Assum that there is one date dimension table in your model, you can create a calculated column as below to get the number of days between two dates. Please find the details in the attachment.

No.of Days =
VAR _enddate =
    IF ( ISBLANK ( 'Table'[End Date] ), TODAY (), 'Table'[End Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Date' ),
        DATESBETWEEN ( 'Date'[Date], 'Table'[Start Date], _enddate ),
        FILTER ( 'Date', WEEKDAY ( 'Date'[Date], 2 ) < 6 )
    )

yingyinr_0-1665970301166.png

In addition, you can refer the following blog to get it by DAX or Power Query method...

Calculate Workdays Between Two Dates In Power BI

yingyinr_1-1665970540703.png

Best Regards

lbendlin
Super User
Super User

Please read about the NETWORKDAYS() function.

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.