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
BobKoenen
Helper IV
Helper IV

Distribute amount over working days based on start end date

HI all, 

 

I want to calculate the amount of leave per working day for capacity insights. 

My data looks like this

 

NameStart dateEnd dateHoursType of leave
Joe1-1-20214-1-202116Holliday
Jill4-1-20207-1-202140Parent leave
Body5-1-20207-1-202132Overtime comp.

 

I want my measure to look like this

Date

Measure sum of leave
1-1-20218
2-1-20210
3-1-20210
4-1-20218
5-1-202116
6-1-202116
7-1-202116

 

Would i need to add a working day column in my date table?

 

Hope you can help me

1 ACCEPTED SOLUTION

sorry figured it out already

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

Hey @BobKoenen ,

 

I think the easiest approach is in Power Query to expand the date range to all of the dates.

Then you can just do a COUNTROWS and it will show you the correct amount per day.

 

Try the following M-Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8spPVdJRMtQ11DUyMDIEMk0QTEMzIOGRn5OTmZJYqRSrA1SdmZODUGMAZJoj6QTxAxKLUvNKFHJSE8tSwVqc8lMqgeKmWLUYGwEJ/7LUopLM3FSF5PzcAj2l2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Start date" = _t, #"End date" = _t, Hours = _t, #"Type of leave" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Start date", type date}, {"End date", type date}, {"Hours", Int64.Type}, {"Type of leave", type text}}),
    #"Changed Date to Number" = Table.TransformColumnTypes(#"Changed Type",{{"Start date", Int64.Type}, {"End date", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Date to Number", "DateRange", each {[Start date] .. [End date]}),
    #"Expanded DateRange" = Table.ExpandListColumn(#"Added Custom", "DateRange"),
    #"Changed back to date" = Table.TransformColumnTypes(#"Expanded DateRange",{{"Start date", type date}, {"End date", type date}, {"DateRange", type date}})
in
    #"Changed back to date"

 

The result will look like this:

selimovd_0-1626987911085.png

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

HI DenSel,

 

Thankx but this does not give me a tabel with only values on working days. I think this gets my only halfway

sorry figured it out already

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.