cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User IV
Super User IV

Re: Calculate StartDate + Working hours to determine ClosedDate

@javirmerino did you tested what I mentoned. Adding custom column in query editor? If yes, what is the issue with it?






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

Proud to be a Datanaut! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Super User IV
Super User IV

Re: Calculate StartDate + Working hours to determine ClosedDate

@javirmerino I just read your reply to my original answer and I see where my solution wouldn't work as you want to consider only working hours. I guess @Greg_Deckler  is always on it with you. You are in safe hands!! 🙂






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

Proud to be a Datanaut! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
javirmerino Helper III
Helper III

Re: Calculate StartDate + Working hours to determine ClosedDate

Thanks @Greg_Deckler , i'll give that a go this morning and will let you know my outcome.

 

The last challenge will be for me to resolve the start point of requests raised outside of office hours; unless this will account for that also?

javirmerino Helper III
Helper III

Re: Calculate StartDate + Working hours to determine ClosedDate

This looks to be pretty much what i need; the only changes i need to make now are around the start time of the "timer"; from the look of your code, its hard-coded to start from 9am regardless.

 

If its received in working hours then the time should start from then, but if its out of hours then it should start from 9am the next working day...

Super User IV
Super User IV

Re: Calculate StartDate + Working hours to determine ClosedDate

I'll have to take a look, from what I recall that should be accounted for but will have to confirm that. Will have to fire up the pbix and put that use case in. If it is a problem, shouldn't be that big of a deal to account for it.

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Super User IV
Super User IV

Re: Calculate StartDate + Working hours to determine ClosedDate

@javirmerino  - OK, minor change required. I think this covers your additional use case now. Updated PBIX attached.

 

DueDate = 
    IF(
        NOT(ISBLANK([Required Completion Date])),
        [Required Completion Date],
            VAR __HourTime = 1/24*[Hours]
            VAR __Dates = FILTER('Calendar',[Date]>=[Received].[Date])
            VAR __Table = 
                ADDCOLUMNS(
                    __Dates,
                    "__WorkTime",SUMX(FILTER(__Dates,[Date]<=EARLIER([Date])),[Working Time])
                )
            VAR __TargetDate = MINX(FILTER(__Table,[__WorkTime] >= __HourTime),[Date])
            VAR __TargetDateTime = 
                IF(
                    HOUR([Received]) > 17 || (HOUR([Received])=17 && MINUTE([Received]) > 0),
                    __TargetDate + 1 + 1/24*9, //start at 9AM,
                    __TargetDate + 1/24*9 //start at 9AM
                )
            VAR __TimeLeft = MAXX(FILTER(__Table,[Date]=__TargetDate),[__WorkTime]) - __HourTime
            VAR __Target = 
                IF(
                    __TargetDate = [Received],
                    [Received]+__TimeLeft,
                    __TargetDateTime + __TimeLeft
                )
            VAR __FinalTarget = 
                IF(
                    HOUR(__Target) > 17 || (HOUR(__Target)=17 && MINUTE(__Target) > 0),
                    __TargetDateTime + 1 + (__Target - (__TargetDateTime + 1/24*8)),
                    __Target
                )
        RETURN
            __FinalTarget
    )

  


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

javirmerino Helper III
Helper III

Re: Calculate StartDate + Working hours to determine ClosedDate

Thanks @Greg_Deckler . I've been giving your previous code a go, but it's freezing my pc each time! I've now created an extract version to test it on though as i'm hoping its something to do with the directquery connection...

i'll try this out too.

Super User IV
Super User IV

Re: Calculate StartDate + Working hours to determine ClosedDate

Ah, well I was not focused on making this Direct Query friendly. I'll have to check to make sure that all of the functions are compatible with Direct Query. Also, I would have to take a critical eye towards this with respect to performance. There is lots of iteration going on here. How many rows are we talking?


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

javirmerino Helper III
Helper III

Re: Calculate StartDate + Working hours to determine ClosedDate

Around 10,000 rows per year, give or take. Not huge volumes but obviously enough if theres several iterations happening each time.

It's frozen as an extract as well now, though!

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors