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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Karthik12
Helper V
Helper V

no of worked days and remaining working days between choosen days

Team,

I would like to calculate no of worked days between 26th Nov 2022 till yesterday and

remaining working days from today to 31st december (Exclude Sundays and specified holidays)

 

Can someone please help?

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I suggest having a calendar table with holiday indicating column like below.

I tried to create a sample pbix file like below.

I hope the below can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_0-1670225746389.png

 

 

No of workdays from 26Nov until yesterday: =
VAR _startdate =
    DATE ( 2022, 11, 26 )
VAR _yesterday =
    TODAY () - 1
VAR _exceptholidayandsunday =
    FILTER (
        'Calendar',
        'Calendar'[Holiday] <> 1
            && 'Calendar'[Day Name] <> "Sunday"
            && 'Calendar'[Date] >= _startdate
            && 'Calendar'[Date] <= _yesterday
    )
RETURN
    COUNTROWS ( _exceptholidayandsunday )

 

No of workdays from today until 31Dec: = 
VAR _startdate =
    TODAY()
VAR _enddate =
    DATE(2022,12,31)
VAR _exceptholidayandsunday =
    FILTER (
        'Calendar',
        'Calendar'[Holiday] <> 1
            && 'Calendar'[Day Name] <> "Sunday"
            && 'Calendar'[Date] >= _startdate
            && 'Calendar'[Date] <= _enddate
    )
RETURN
    COUNTROWS ( _exceptholidayandsunday )

 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

@Karthik12 sorry I forgot to remove -1

 

No of days till 31 st Dec = var _D = DATE(2022,12,31)
 return
     NETWORKDAYS(TODAY(),_D,11)

For holiday and other detail please go through doc: https://learn.microsoft.com/en-us/dax/networkdays-dax

View solution in original post

5 REPLIES 5
Karthik12
Helper V
Helper V

@ddpl @Jihwan_Kim thank you both. It works fine for me.

ddpl
Solution Sage
Solution Sage

@Karthik12 try this

Working days till Yesterday = var _D = DATE(2022,11,26)
return
NETWORKDAYS(_D,TODAY()-1,11)
No of days till 31 st Dec = var _D = DATE(2022,12,31)
 return
     NETWORKDAYS(TODAY()-1,_D,11)

For holiday and other detail please go through doc: https://learn.microsoft.com/en-us/dax/networkdays-dax

@ddpl Thanks for the input. It works fine for working days till yesterday. But, remaining days was increased one day while compared to yesterday.

Actually It should be reduced one day.

Can you please check?

@Karthik12 sorry I forgot to remove -1

 

No of days till 31 st Dec = var _D = DATE(2022,12,31)
 return
     NETWORKDAYS(TODAY(),_D,11)

For holiday and other detail please go through doc: https://learn.microsoft.com/en-us/dax/networkdays-dax
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I suggest having a calendar table with holiday indicating column like below.

I tried to create a sample pbix file like below.

I hope the below can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_0-1670225746389.png

 

 

No of workdays from 26Nov until yesterday: =
VAR _startdate =
    DATE ( 2022, 11, 26 )
VAR _yesterday =
    TODAY () - 1
VAR _exceptholidayandsunday =
    FILTER (
        'Calendar',
        'Calendar'[Holiday] <> 1
            && 'Calendar'[Day Name] <> "Sunday"
            && 'Calendar'[Date] >= _startdate
            && 'Calendar'[Date] <= _yesterday
    )
RETURN
    COUNTROWS ( _exceptholidayandsunday )

 

No of workdays from today until 31Dec: = 
VAR _startdate =
    TODAY()
VAR _enddate =
    DATE(2022,12,31)
VAR _exceptholidayandsunday =
    FILTER (
        'Calendar',
        'Calendar'[Holiday] <> 1
            && 'Calendar'[Day Name] <> "Sunday"
            && 'Calendar'[Date] >= _startdate
            && 'Calendar'[Date] <= _enddate
    )
RETURN
    COUNTROWS ( _exceptholidayandsunday )

 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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