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

Getting all dates between 2 dates excluding weekends

Hello, 

 

I found this https://community.powerbi.com/t5/Desktop/Getting-all-dates-between-2-dates/m-p/60577/page/2 post, its works however when I wanna apply changes, it says that its not supported  and i cant transfer it to my dashboard. Any suggestions? 

 

Also  is there a way to use networkdays while using this PowerQuery M Method? I would like to display only working days between these dates 🙂 

 

VL345_0-1668532513526.png

 

Thank you!!!

3 REPLIES 3
v-rongtiep-msft
Community Support
Community Support

Hi @VL345 ,

 Please refer to my pbix file to see if it helps you.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwNNM31jcyVNKBs82UYnWgMqb6pjAJU31zqLiRkb6hob6hAVgGwjEyVYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [startdate = _t, enddate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"startdate", type date}, {"enddate", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each { Number.From([#"startdate"])..Number.From([#"enddate"]) }),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each Date.DayOfWeek([Custom],Day.Monday)),
    #"Added Conditional Column" = Table.AddColumn(#"Added Custom1", "Custom.2", each if [Custom.1] >= 5 then "" else [Custom]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Custom", "Custom.1"})
in
    #"Removed Columns"

vpollymsft_0-1669620870588.png

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Syndicate_Admin
Administrator
Administrator

When you say you want to get all the dates between two dates, you mean you want the sum of those days?

for that there is a function in dax networkingDays q returns the number of working days (you must indicate the holidays of your country ..)

NETWORKDAYS(, [, , ])

https://learn.microsoft.com/en-us/dax/networkdays-dax

Now if what you want is dates like dateTime. I recommend you create another CALENDAR TABLE. Only with the working days. and when you do the beetwen of the two dates you use this table as a reference therefore the DateTime that is there are working days between those two dates ...

I hope I have helped you in something...

Hello,

 

thank you, well so far I am using PowerApps to calculate Working days between these two dates (From / To) its working, but I need also sequence of days per day. 

 

The reason : I am doing a lot of calculation and the idea is to view these calculations based on month and quarters and I cant think of any other solution how to incorporate it. So far its displaying my calculation only based on name, country etc...

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.