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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
lk94
Regular Visitor

Building Excel WORKDAY-Function in Power BI

Hi everyone,

 

I need a function in PowerBI, which provides the same features like the WORKDAY-function in excel. So I want to add several days to a date in consideration of weekends and holidays.

The holidays are in a seperate table. The days, which should be added, are not same for every line and depends on a value, given in the respective line. Also the date, i want to add these days, are given in the respective line.

 

Thank you for your help. Kind

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User
3 REPLIES 3
Vera_33
Resident Rockstar
Resident Rockstar

Hi @lk94 

 

This is a custom function in M

 

(StartDate as data, EndDate as dateoptional Holiday as tableas number =>

let
    ListOfHolidays = if Holiday = null then {} else Table.Column(Holiday, "Date"), // put your own column name
    NumListOfHolidays = List.Transform(ListOfHolidays, each Number.From(_)),
    ListOfDays = if StartDate > EndDate then {Number.From(EndDate)..Number.From(StartDate)} else {Number.From(StartDate)..Number.From(EndDate)},
    ListDiff = List.Difference(ListOfDays,ListOfHolidays),
    ListSel = List.Select(
        List.Transform(ListDiff, each Date.DayOfWeek(Date.From(_), Day.Saturday)), each _ >1
    ),
    Result = if StartDate = null or EndDate = null then null 
        else if StartDate > EndDate then (List.Count(ListSel)-1)*(-1)
        else List.Count(ListSel) -1
in
    Result      
Greg_Deckler
Community Champion
Community Champion

@lk94 - Check out Net Work Days - https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/td-p/367362

 

Also, Excel to DAX Translation - https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

 

Finally since I see you are a New Member some additional useful links: 

https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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