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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to generate hours that are allocated based on date and machine

Hi all,

 

May need your help in to solve an issue that i currently face . I am currently stuck and no idea if this is possible to do in PowerBI (currently doing it in excel and would like to automate the report ).  I have a case where we need to monitor the loading for each machine that are assigned  . So each job number will be having balance hours and days remaining for it to complete the job. I have created a calendar table that are connected to the job operation date. My main question is how do i generate hours (balancehours / days ) to get an output similar as below . 

 

Hairul_Khumaini_2-1687329938420.png

 

Hairul_Khumaini_0-1687341906694.png

(above is the expected out but in excel .. the chart is based on week , i would like by date so that I can monitor by weekly , month and year)

 

I have few conditions also:

-The hours divided must be within job start date (JobOper_StartDate) and end date (JobDue_Duedate) .  

-Job that are passed due date not need to generate and will go to backlog hours as shown in chart

 

So the expected output : We are able to sum the total hours divided based on date , month and also based on machine(resource) . 

 

Here are sample data for factory loading :

 

Calculated_BalanceHrsDaysJob NumJobOper_StartdateJobOper_DueDateResource
34.71217200828-Jun-2327-Jun-23CM4
20.93417263118-Sep-2315-Sep-23CM4
24.48317263207-Jul-2305-Jul-23CM3
32.78317263723-Jun-2321-Jun-23CM2
14.58217268414-Jul-2313-Jul-23CM2
6.38217268713-Jul-2312-Jul-23CM2
10.04217269407-Jul-2306-Jul-23CM2
35.18617272027-Jun-2322-Jun-23CM3
12.85217280916-Jun-2315-Jun-23CM4
6.79217281827-Jun-2326-Jun-23CM4
71.27416529424-Nov-2321-Nov-23CM1
36.76516817722-Aug-2318-Aug-23CM1
34.48617029206-Dec-2301-Dec-23CM1
34.48217029303-Nov-2302-Nov-23CM1
34.48617029404-Oct-2329-Sep-23CM1
34.48617029506-Sep-2301-Sep-23CM1
34.48217029604-Aug-2303-Aug-23CM1
14.7517030028-Nov-2324-Nov-23CM1
14.7517030226-Sep-2322-Sep-23CM1
14.7517030329-Aug-2325-Aug-23CM1
14.7217030428-Jul-2327-Jul-23CM1
14.7517030527-Jun-2323-Jun-23CM1
67.74817188018-Aug-2311-Aug-23CM2
130.441517188105-Oct-2321-Sep-23CM1
21.15217188328-Jul-2327-Jul-23CM1
40.65717188426-Sep-2320-Sep-23CM1
43.56417188530-Jun-2327-Jun-23CM4
91.161017188605-Oct-2326-Sep-23CM1
19.72217213903-Aug-2302-Aug-23CM4
19.72217214006-Jul-2305-Jul-23CM4
14.3417214310-Jul-2307-Jul-23CM4
1.8217245429-Jun-2328-Jun-23CM2
21.45217252419-Jul-2318-Jul-23CM1
24.84217262304-Jul-2303-Jul-23CM4
8.36217262713-Sep-2312-Sep-23CM4
8.36217262805-Jul-2304-Jul-23CM2
19.96217262914-Sep-2313-Sep-23CM4
19.96217263005-Jul-2304-Jul-23CM3
45.3417268114-Jul-2311-Jul-23CM3
4.39417268519-Jun-2316-Jun-23CM4
25.4617271104-Jul-2329-Jun-23CM3
22.95317271229-Jun-2327-Jun-23CM3
44.31717271321-Jun-2315-Jun-23CM2
3.55116695721-Jun-2321-Jun-23CM2
6.56017153316-May-2316-May-23CM1
4.48117208823-Jun-2323-Jun-23CM2
4.49116803229-Aug-2329-Aug-23CM1

 

Thanks in Advance.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the input but what i am missing was another step .Issue with above it will not show the exact divided hours by day. The solution that I found is I use List and I generate row using Power Query .This will generate row based on start and due date . 

 

List.Select(List.Dates([JobOper_StartDate], Duration.Days([JobOper_DueDate] - [JobOper_StartDate]) + 1, #duration(1, 0, 0, 0)), each Date.DayOfWeek(_) >= 0 and Date.DayOfWeek(_) <= 4)

(this list will also exclude weekend)

 

And after that I just divided by hours and it will show by day, month and week.

 

View solution in original post

8 REPLIES 8
some_bih
Super User
Super User

Hi @Anonymous ok, to be precise as much as possible, please provide sample output from your table above or you just need simple division for "calculated balancehours/days) "?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Anonymous
Not applicable

Hi @some_bih,  My goal is to divide the calculate balance hours from job start date and due date ( i get the days from deducting from these dates) and plot a chart based on date. If i do a simple divide i would not get the divided hours on the days between start date and due date.

@Anonymous  to provide some possible solution please provide expected output from your sample data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Anonymous
Not applicable

hi @some_bih , i have updated the post with the expected output  . Basically the table in excel (below the chart) is what i what i want the output . In the expected output is by week . But i want it by date(daily) so that I can plot a chart monthly.

Hi @Anonymous based on your sample data I created calculated column 

Min_Date = MIN(Sheet2[JobOper_Startdate],Sheet2[JobOper_DueDate])
This column is date key column fot Date table. Date table for week overiew is crated by solution by SQLBI on link https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/ . With Date table you can see data by week and by month as shown on picture below. 

Adjust Sheet 2 to your table name and created two simple measure 

Sum hours = SUM(Sheet2[Calculated_BalanceHrs])
Sum backlog = SUM(Sheet2[Backlog])
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
 
 

 

some_bih_0-1687415327468.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Anonymous
Not applicable

Thanks for the input but what i am missing was another step .Issue with above it will not show the exact divided hours by day. The solution that I found is I use List and I generate row using Power Query .This will generate row based on start and due date . 

 

List.Select(List.Dates([JobOper_StartDate], Duration.Days([JobOper_DueDate] - [JobOper_StartDate]) + 1, #duration(1, 0, 0, 0)), each Date.DayOfWeek(_) >= 0 and Date.DayOfWeek(_) <= 4)

(this list will also exclude weekend)

 

And after that I just divided by hours and it will show by day, month and week.

 

some_bih
Super User
Super User

Hi @Anonymous to calculate difference in HOURS, DAYS, or other time frame in DAX there is function DATEDIFF. Check link for example and choose your time frame. Hope this help

https://learn.microsoft.com/en-us/dax/datediff-function-dax?WT.mc_id=DP-MVP-4025372 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Anonymous
Not applicable

Hi @some_bih , what i want to produce is the divided hours(calculated balancehours/days) based on the job start date and due date and able to plot into bar chart based on dates and resource

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors