cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Daxtothemax
Regular Visitor

Rollover Hours Calculation

I need some help with a DAX formula that can capture the balance of rollover hours per day.  Example data below is below.  

 

On the first day 10 hours of work was assigned but only 5 hours were completed, resulting in a 5 hour balance.  The next day 20 hours of additional work was assigned and 10 hours were completed, which results in 10 hours for that day plus 5 from the previous day.  I'm looking for a DAX formula that would do this calculation in the Rollover Balance column. I believe I need to use the EARLIER function but I cant seem to get it right. 

 

Daxtothemax_1-1638479209992.png

 

 

Any help is greatly appreciated!

 

 

 

1 ACCEPTED SOLUTION
RicoZhou
Community Support
Community Support

Hi @Daxtothemax ,

You can try this code to create a calculated column by EARLIER() function.

Rollover Balance = 
CALCULATE (
    SUM ( 'Table'[Daily Hours of Work] ) - SUM ( 'Table'[Daily Hours Completed] ),
    FILTER ( 'Table', 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
RicoZhou
Community Support
Community Support

Hi @Daxtothemax ,

You can try this code to create a calculated column by EARLIER() function.

Rollover Balance = 
CALCULATE (
    SUM ( 'Table'[Daily Hours of Work] ) - SUM ( 'Table'[Daily Hours Completed] ),
    FILTER ( 'Table', 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

Ashish_Mathur
Super User
Super User

Hi,

  1. Create a Calendar Table
  2. Build a relationship between the Date column of your Data Table to the Date column of your Calendar Table
  3. To your Table visual, drag Date from the Calendar Table
  4. Write these measures
    1. Daily hours of work = sum(Data[daily hours])
    2. Daily hours of work till date = calculate([Daily hours of work],datesytd(calendar[Date],"31/12))
    3. Daily hours completed = sum(Data[hours completed])
    4. Daily hours completed till date = calculate([Daily hours completed],datesytd(calendar[Date],"31/12))
    5. Rollover balance = [Daily hours of work till date]-[Daily hours completed till date]

Hope this helps.


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

@Daxtothemax , You need to calculate Cumulative  measure

 

Calculate(Sum(Table[Daily Work Hours]) - Sum(Table[Daily Hours completed]) , filter( allselected(Table), Table[Date]<= Max(Table[Date]) ) )

 

or

with date table

Calculate(Sum(Table[Daily Work Hours]) - Sum(Table[Daily Hours completed]) , filter( allselected(Date), Date[Date]<= Max(Date[Date]) ) )

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors