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
mmilegal
Frequent Visitor

Work In Progress report from time recording data

Hello to the community

 

Could I please ask for your help?

 

I would like to use time-recording data combined with billing date data to create a Work-In-Progress or unbilled hours report.  I have found many tutorials on working with cumulatives but have failed to find a way to use them in my own implementation.  I'm sure the answer is out there but the search terms I've been using have failed to unearth it so it may be clearest if I show very basic sample data and the output I hope to generate from that.  

 

Example of the table imported from my source:

Job NumberAction dateAction DurationBilling Date
123401 January 2017110 April 2017
123410 January 2017410 April 2017
123412 February 2017910 April 2017
123412 March 2017710 April 2017
123402 April 2017210 April 2017
456707 January 2017802 July 2017
456710 March 2017702 July 2017
456728 April 2017402 July 2017
456710 June 2017502 July 2017
678921 March 20171226 April 2017
678901 April 2017326 April 2017
678908 April 2017526 April 2017
678912 April 2017426 April 2017

 

Format of output I hope to achieve:

 

Job NumberJanFebMarAprMayJune
123451421000
45678815191924
67890012000

 

So, job 1234 had 5 hours worked in Jan that were unbilled at the end of Jan, so 5 hours was unbilled at that point.  9 hours were added in Feb and 7 in March resulting in 14 and 21 hours 'in-progress' at those month ends respectively.  Although 2 hours were added in April, the work was billed in full within that month resulting in a zero balance at the end of April.  

 

In my scenario, not all jobs will have a billing date.  The absence of a billing date should be interpreted as a future billing date i.e. unbilled hours will accrue or carry forward until a billing date is entered.  My scenario does not need to handle partial billings or write-offs i.e. a billing date will negate all unbilled hours to date and result in a period end aggregate of zero.  

 

Apologies in advance for the length of the post and the almost inevitable duplication of the question.  I know my first post comes only minutes after registering but I have searched this forum and the wider web for a couple of (fruitless) days - I promise!

 

Thank you in advance for any help you can offer.  

 

Kind regards

 

GF

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@mmilegal

You can create a calendar table 

calendar = CALENDAR(MIN(yourTable[Action date]),MAX(yourTable[Action date]))

Month = EOMONTH('calendar'[Date],0)

Capture.PNG

 

Then create a measure as below.

unBilledHoursTotal =
VAR unBilledHoursInTotal =
    SUMX (
        FILTER (
            FILTER (
                ALLSELECTED ( yourTable ),
                yourTable[Job Number] = MAX ( yourTable[Job Number] )
            ),
            yourTable[Action date] <= MAX ( 'calendar'[Month] )
        ),
        yourTable[Action Duration]
    )
VAR isCurrentMonthBillMonth =
    DATE ( YEAR ( MAX ( yourTable[Billing Date] ) ), MONTH ( MAX ( yourTable[Billing Date] ) ), 1 )
        = DATE ( YEAR ( MAX ( 'calendar'[Month] ) ), MONTH ( MAX ( 'calendar'[Month] ) ), 1 )
VAR billDate =
    IF (
        ISBLANK ( MAX ( yourTable[Billing Date] ) ),
        DATE ( 2099, 1, 1 ),
        MAX ( yourTable[Billing Date] )
    )
RETURN
    SWITCH (
        TRUE (),
        ISBLANK ( unBilledHoursInTotal ), 0,
        isCurrentMonthBillMonth, 0,
        MAX ( 'calendar'[Month] ) >= billDate, 0,
        unBilledHoursInTotal
    )

Capture.PNG

 

See more details in the attached pbix file.

View solution in original post

4 REPLIES 4
mmilegal
Frequent Visitor

@Eric_Zhang @Ashish_Mathur @fhill

 

Many thanks to you all for your helpful suggestions.  The fact you each provided slightly different solutions is tremendously helpful.  Some time spend deconstructing your suggestions combined with revisiting msdn's help pages on DAX is so much more helpful than just the msdn pages alone.  Seeing how the commands can be used in a familiar scenario is like accelerated learning!

 

I now not only have a solution to my immediate problem but am better equipped to deal with the next one!  Your generosity with your time and knowledge is greatly appreciated.  

You are most welcome.  Thank you for your kind words.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi @mmilegal,

 

You may refer to my solution here.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Eric_Zhang
Employee
Employee

@mmilegal

You can create a calendar table 

calendar = CALENDAR(MIN(yourTable[Action date]),MAX(yourTable[Action date]))

Month = EOMONTH('calendar'[Date],0)

Capture.PNG

 

Then create a measure as below.

unBilledHoursTotal =
VAR unBilledHoursInTotal =
    SUMX (
        FILTER (
            FILTER (
                ALLSELECTED ( yourTable ),
                yourTable[Job Number] = MAX ( yourTable[Job Number] )
            ),
            yourTable[Action date] <= MAX ( 'calendar'[Month] )
        ),
        yourTable[Action Duration]
    )
VAR isCurrentMonthBillMonth =
    DATE ( YEAR ( MAX ( yourTable[Billing Date] ) ), MONTH ( MAX ( yourTable[Billing Date] ) ), 1 )
        = DATE ( YEAR ( MAX ( 'calendar'[Month] ) ), MONTH ( MAX ( 'calendar'[Month] ) ), 1 )
VAR billDate =
    IF (
        ISBLANK ( MAX ( yourTable[Billing Date] ) ),
        DATE ( 2099, 1, 1 ),
        MAX ( yourTable[Billing Date] )
    )
RETURN
    SWITCH (
        TRUE (),
        ISBLANK ( unBilledHoursInTotal ), 0,
        isCurrentMonthBillMonth, 0,
        MAX ( 'calendar'[Month] ) >= billDate, 0,
        unBilledHoursInTotal
    )

Capture.PNG

 

See more details in the attached pbix file.

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.