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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PaulMac
Helper IV
Helper IV

Converting a simple Formula to Work in Power BI

Hi

 

We have a very simple formula in an Excel workbook:

 

=WORKDAY($A2,9,BankHolidays)

 

This takes the date that sits in cell A2, adds on 9 working days, excluding any Bank Holiday dates that are present in the BankHolidays table. Simple.

But trying to accomplish the same thing in Power BI using DAX or M Lang is not so simple, at least from what I am finding.

I have tried to produce the following DAX but unfortnately I get a widly incorrect date.

 

10 Day Letter Due =
NETWORKDAYS (
    table1[Date Received],
    DATEADD ( table1[Date Received], 9, DAY ),
    1,
    tblPublicHolidayDates
)

 

If anyone is able to assist with a simple and ellgant solution to this, it would be very much appreciated.

Thanks,
Paul

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@PaulMac,

 

Try this calculated column in Table1. It requires a Dates table with columns Is Weekday and Is Holiday.

 

10 Day Letter Due =
VAR vDaysToAdd = 9
VAR vStartDate =
    Table1[Date Received]
VAR vWorkdaysAfterStartDate =
    FILTER (
        Dates,
        Dates[Date] > vStartDate
            && Dates[Is Weekday] = 1
            && Dates[Is Holiday] = 0
    )
VAR vResult =
    MAXX (
        TOPN ( vDaysToAdd, vWorkdaysAfterStartDate, Dates[Date], ASC ),
        Dates[Date]
    )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
PaulMac
Helper IV
Helper IV

Thank you @DataInsights 
That did the job perfectly!
Paul

DataInsights
Super User
Super User

@PaulMac,

 

Try this calculated column in Table1. It requires a Dates table with columns Is Weekday and Is Holiday.

 

10 Day Letter Due =
VAR vDaysToAdd = 9
VAR vStartDate =
    Table1[Date Received]
VAR vWorkdaysAfterStartDate =
    FILTER (
        Dates,
        Dates[Date] > vStartDate
            && Dates[Is Weekday] = 1
            && Dates[Is Holiday] = 0
    )
VAR vResult =
    MAXX (
        TOPN ( vDaysToAdd, vWorkdaysAfterStartDate, Dates[Date], ASC ),
        Dates[Date]
    )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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