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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anthony_2022
New Member

How to calculate the estimate hour per day per project with realized hours in the same visual?

I try to present the realized hours versus the planned hours for several projects in the same graph.

 

I've done a lot of research, the answers revolve around creating a calculate column to get the estimated hours. This always answers the need of the original question. However, in my case, it can't work since I have several projects, therefore several estimates. I don't see how to procedurally create these calculated columns. (In my real data, I have several hundred projects)

 

I am able to get the expected number of hours for each day. However, the planned hours stop where the last hour entered is.

2022-02-01 14_34_13-Window.png

I suspect that this is a matter of filters or assigning a new date table to the DAX formula.

 

I have another table that consists of a table of dates. The relationship between the two tables is on the date column.

 

Data sample :

Dates | Project Hours | End_Date | Total_Estimate_Hours

2022-02-01Project A12022-02-2850
2022-02-02Project A12022-02-2850
2022-02-03Project A12022-02-2850
2022-02-04Project A12022-02-2850
2022-02-05Project A12022-02-2850
2022-02-06Project A12022-02-2850
2022-02-07Project A12022-02-2850
2022-02-08Project A12022-02-2850
2022-02-09Project A12022-02-2850
2022-02-10Project A12022-02-2850
2022-02-11Project A12022-02-2850
2022-02-12Project A12022-02-2850
2022-02-13Project A32022-02-2850
2022-02-14Project A82022-02-2850
2022-02-15Project A12022-02-2850
2022-02-16Project A12022-02-2850
2022-02-17Project A12022-02-2850
2022-02-18Project A12022-02-2850
2022-02-01Project B22022-02-2628
2022-02-03Project B32022-02-2628
2022-02-04Project B22022-02-2628
2022-02-09Project B22022-02-2628
2022-02-10Project B52022-02-2628
2022-02-12Project B32022-02-2628
2022-02-13Project B42022-02-2628
2022-02-16Project B22022-02-2628
4 REPLIES 4
AUaero
Responsive Resident
Responsive Resident

I don't really understand your sample data vs the screenshots you posted.  It looks like the actual and estimated hours in your graphs are cumulative sums.  Can you post the raw data for hours and estimates for a couple of projects along with your measure defintions?

I'm sorry, I forgot to put the DAX formulas. I hadn't included them since I intended to add a PBIX file, but I couldn't find a way to attach it to the post.

 

Here is the DAX formula for realized hours:

Realized hours = 
VAR LastVisibleDate = MAX(Dates[Date])
Var FirstVisibleDate = MIN(Dates[Date])
Var LastDateWithHours = CALCULATE(MAX('Table'[Dates]),REMOVEFILTERS())
Var Result = IF(FirstVisibleDate <= LastDateWithHours, CALCULATE(SUM('Table'[Hours]),dates[date] <= LastVisibleDate))
return Result

Here is the DAX formula for estimated hours:

Estimate Hours = 
VAR LastVisibleDate = MAX('Table'[End Date])
Var FirstVisibleDate = MIN(Dates[Date])
VAR DayBetweenDates = DATEDIFF(FirstVisibleDate,LastVisibleDate,DAY)

return SELECTEDVALUE('Table'[Total Estimate Hours])/DayBetweenDates

The sample data are identical to my source data, they have been ultra simplified to facilitate finding a solution.

The hours data have been aggregated for performance reasons. Initially, it was a table with multiple rows per day per user per project.

The projects data was a table by itself. It was combined with the previous table to facilitate the application of filters and measurements. This seemed to be the best decision in terms of performance, but I haven't measured it until now because of the concern initially presented.

Hi, @Anthony_2022 

 

What kind of results do you expect? I have made some adjustments, please check if it meets your needs.

Realized hours = 
VAR LastVisibleDate = SELECTEDVALUE('Table'[Date])
Var FirstVisibleDate = CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),[Project]=MAX('Table'[Project])))
Var LastDateWithHours = CALCULATE(MAX('Table'[Date]),REMOVEFILTERS())
Var Result = IF(FirstVisibleDate <= LastDateWithHours, CALCULATE(SUM('Table'[Hours]),FILTER(ALL('Table'),'Table'[Date] <=LastVisibleDate&&[Project]=MAX('Table'[Project]))))
return Result
Estimate Hours = 
VAR LastVisibleDate = SELECTEDVALUE('Table'[End_Date])
Var FirstVisibleDate = MIN('Table'[Date])
VAR DayBetweenDates = DATEDIFF(FirstVisibleDate,LastVisibleDate,DAY)
return SELECTEDVALUE('Table'[Total_Estimate_Hours])/DayBetweenDates

vzhangti_0-1644385495461.png

If the method I provided above can't solve your problem, what's your expected result? Please provide a display photo of the desired result.

 

Best Regards,

Community Support Team _Charlotte

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

 

Hi @v-zhangti ,

 

Thank you for the answer.

 

Unfortunately, that doesn't answer the question.

 

The result I'm trying to achieve is to validate if we're going under the hourly budget or if it's costing us more time before we get to the end of the project.


To get closer to this result, I had to add a Start Date column to my data. I managed to get the desired modeling with this DAX formula:

 

Estimate Hours 4 = 
CALCULATE (
    DATEDIFF (
        SELECTEDVALUE ( 'Table'[Start Date] ),
        SELECTEDVALUE ( Dates[Date] ),
        DAY
    )
        * DIVIDE ( SELECTEDVALUE ( 'Table'[Total Estimate Hours] ), [Datediff] ),
    ALLEXCEPT ( Dates, Dates[Date] )
)

 

2022-02-09 22_20_22-Window.png

 

I still have the concern to have the estimated hours beyond the realized data. Here is a dummy example that I want to achieve:

2022-02-09 22_21_49-Window.png

Here what my model looks like:
2022-02-09 22_28_49-Window.png

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors