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

Day list between 2 dates without weekend

Hi,

I have created a custom column to get all the days between 2 dates, but I want to exclude saturday and sundays

#"Added Custom" = Table.AddColumn(#"Changed Type3", "Transaction Date", each { Number.From([Start Date])..Number.From([End Date]) })

Is there a way to do that?

Here is the full code of the section, but it ends in error

#"Added Custom" = Table.AddColumn(#"Changed Type3", "Transaction Date", each { Number.From([Start Date])..Number.From([End Date]) }),
#"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"id", "Status", "Offering", "Client", "Candidate", "Start Date", "Scheduled End", "End Date", "Transaction Date", "Revenue Cost Center", "Assignment Number", "Pay Rate $", "Client Bill Rate $", "Worker Type", "Branch", "Detailed Job Code", "Job Type", "JobOrder.owner", "Candidate.owner", "Owner", "Back Office Status", "Back Office Indicator", "End Reason", "# Changes Waiting Approval"}),
#"Expanded Transaction Date" = Table.ExpandListColumn(#"Reordered Columns", "Transaction Date"),
#"Changed Type4" = Table.TransformColumnTypes(#"Expanded Transaction Date",{{"Transaction Date", type date}}),
#"Delete Weekend" = Table.TransformColumns(#"Changed Type4",{{"Transaction Date", each Date.DayOfWeek(_,firstDayOfWeek)<5}}),

Thanks!

Luz

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @luzsoulez ,

 

Try using this calculation in a new custom column. You should be able to remove a number of your steps once implemented:

List.Select(
    List.Transform(
        {Number.From([Start Date])..Number.From([End Date])},
        each Date.From(_)
    ),
    each Date.DayOfWeek(_, 1) < 5
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @luzsoulez ,

 

Try using this calculation in a new custom column. You should be able to remove a number of your steps once implemented:

List.Select(
    List.Transform(
        {Number.From([Start Date])..Number.From([End Date])},
        each Date.From(_)
    ),
    each Date.DayOfWeek(_, 1) < 5
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




That was great, thanks!

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.

Top Solution Authors
Top Kudoed Authors