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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
malvaro
Regular Visitor

Distribute Budget (Hours / Cost) between Start and Finish Dates

Hi to all.

I saw some variations of this question asked before but none of them represented exactly the scenario I need to solve.

I use a Project Scheduling software and I'm able to connect to its database getting information like tasks, budgets, start and finish dates (among many other things). With that, I can build Tasks (Dimension) and Start-Finish (Fact) tables as follows:

 

malvaro_0-1654632704162.png

 

malvaro_1-1654632734261.png

 

I need to be able to distribute the budgeted hours evenly over time (no matter what kind of time slicing I choose) in order to get something like this (the actual figures will vary depending on the number of days of visible month):

 

malvaro_0-1654634053607.png

 

I'm really trying hard to get this with one measure. Don't want to create rows in Power Query for each missing day between dates as I may have 20.000 tasks with an average duration of 90 days which would mean almost 2.000.000 additional rows.

Thanks in advance for any help and hope I've been clear enough!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @malvaro ,

According to your description, here's my solution.

1.Create a Month table. Then change the column name to Month.

Month = UNION(VALUES('Start-Finish'[Start]),VALUES('Start-Finish'[Finish]))

2.Create a measure.

Measure =
VAR _Days =
    IF (
        MONTH ( MAX ( 'Start-Finish'[Start] ) ) < MONTH ( MAX ( 'Month'[Month] ) ),
        SWITCH (
            TRUE (),
            MONTH ( MAX ( 'Start-Finish'[Finish] ) ) > MONTH ( MAX ( 'Month'[Month] ) ), DAY ( EOMONTH ( MAX ( 'Month'[Month] ), 0 ) ),
            MONTH ( MAX ( 'Start-Finish'[Finish] ) ) = MONTH ( MAX ( 'Month'[Month] ) ),
                DATEDIFF (
                    EOMONTH ( MAX ( 'Month'[Month] ), -1 ),
                    MAX ( 'Start-Finish'[Finish] ),
                    DAY
                )
        ),
        IF (
            MONTH ( MAX ( 'Start-Finish'[Start] ) ) = MONTH ( MAX ( 'Month'[Month] ) ),
            DATEDIFF (
                MAX ( 'Start-Finish'[Start] ),
                EOMONTH ( MAX ( 'Month'[Month] ), 0 ),
                DAY
            )
        )
    )
VAR _TotalDays =
    DATEDIFF ( MAX ( 'Start-Finish'[Start] ), MAX ( 'Start-Finish'[Finish] ), DAY )
RETURN
    DIVIDE ( _Days, _TotalDays ) * MAX ( 'Tasks'[Budgeted Hours] )

Here, I use the exact number of days when I calculate the progress of each month. When the start or end day is not 15th, this would be more accurate.

In the matrix, put the new Month column in Columns and  the measure in Values, get the result.

vkalyjmsft_0-1654851054523.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

2 REPLIES 2
draxicle1
Helper I
Helper I

Hi @malvaro and @v-yanjiang-msft 

 

I was researching this topic for a very similar requirement I have to yours (this is my post -> Measure for Start and End dates - Summing Mean hou... - Microsoft Fabric Community)

and I came across your post.  I hope you don't mind, as it is a few years old.

 

I too was hoping to create a measure that would place a "mean hours used per day" between the start and end dates, without having the need to create a table with every date.

 

I am intrigued to know if your solution allowed you to cut across any period (days/months/ quarters) to view the sum of hours budgeted across all activities.

 

Thanks and regards,

v-yanjiang-msft
Community Support
Community Support

Hi @malvaro ,

According to your description, here's my solution.

1.Create a Month table. Then change the column name to Month.

Month = UNION(VALUES('Start-Finish'[Start]),VALUES('Start-Finish'[Finish]))

2.Create a measure.

Measure =
VAR _Days =
    IF (
        MONTH ( MAX ( 'Start-Finish'[Start] ) ) < MONTH ( MAX ( 'Month'[Month] ) ),
        SWITCH (
            TRUE (),
            MONTH ( MAX ( 'Start-Finish'[Finish] ) ) > MONTH ( MAX ( 'Month'[Month] ) ), DAY ( EOMONTH ( MAX ( 'Month'[Month] ), 0 ) ),
            MONTH ( MAX ( 'Start-Finish'[Finish] ) ) = MONTH ( MAX ( 'Month'[Month] ) ),
                DATEDIFF (
                    EOMONTH ( MAX ( 'Month'[Month] ), -1 ),
                    MAX ( 'Start-Finish'[Finish] ),
                    DAY
                )
        ),
        IF (
            MONTH ( MAX ( 'Start-Finish'[Start] ) ) = MONTH ( MAX ( 'Month'[Month] ) ),
            DATEDIFF (
                MAX ( 'Start-Finish'[Start] ),
                EOMONTH ( MAX ( 'Month'[Month] ), 0 ),
                DAY
            )
        )
    )
VAR _TotalDays =
    DATEDIFF ( MAX ( 'Start-Finish'[Start] ), MAX ( 'Start-Finish'[Finish] ), DAY )
RETURN
    DIVIDE ( _Days, _TotalDays ) * MAX ( 'Tasks'[Budgeted Hours] )

Here, I use the exact number of days when I calculate the progress of each month. When the start or end day is not 15th, this would be more accurate.

In the matrix, put the new Month column in Columns and  the measure in Values, get the result.

vkalyjmsft_0-1654851054523.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.