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
Robert1981
Helper II
Helper II

Business day countdown

Hi Everyone,

 

I need help with one of my PBI reports.
For the report I need to harmonize the months and find the similar business days. 

Last working day of a month is considered "day 0", the workday prior "day -1", the workday prior to that "day -2".
How can I write a DAX to create this countdown on a calendar. At the bottom is the query code. Wasn't sure how to add the PBI

It is supposed to look something like this:

DateWeekdayBusiness dayWorkday
10/1/202370 
10/2/202311-21
10/3/202321-20
10/4/202331-19
10/5/202341-18
10/6/202351-17
10/7/202360 
10/8/202370 
10/9/202311-16
10/10/202321-15
10/11/202331-14
10/12/202341-13
10/13/202351-12
10/14/202360 
10/15/202370 
10/16/202311-11
10/17/202321-10
10/18/202331-9
10/19/202341-8
10/20/202351-7
10/21/202360 
10/22/202370 
10/23/202311-6
10/24/202321-5
10/25/202331-4
10/26/202341-3
10/27/202351-2
10/28/202360 
10/29/202370 
10/30/202311-1
10/31/2023210



 

 

let
StartDate = Date.StartOfMonth(Today),
EndDate = Date.EndOfMonth(Today),
Duration = Duration.Days(Duration.From(EndDate-StartDate))+61,
Today = DateTime.Date(DateTime.LocalNow()),

Dates = List.Dates(StartDate,Duration,#duration(1,0,0,0)),
#"Converted to Table" = Table.FromList(Dates, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Date"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}}),
#"Inserted Month" = Table.AddColumn(#"Changed Type", "Month No", each Date.Month([Date]), Int64.Type),
#"Inserted Day Name" = Table.AddColumn(#"Inserted Month", "Day Name", each Date.DayOfWeekName([Date]), type text),
#"Inserted Day of Week" = Table.AddColumn(#"Inserted Day Name", "Day of Week", each Date.DayOfWeek([Date]), Int64.Type),
#"Added Custom" = Table.AddColumn(#"Inserted Day of Week", "Business Day", each if [Day of Week]>0 and [Day of Week]<6 then 1 else 0)
in
#"Added Custom"

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

This is immutable, there is no need to do this in DAX.  Use an external calendar table where this is precomputed one time.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

This is immutable, there is no need to do this in DAX.  Use an external calendar table where this is precomputed one time.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.