Forum Discussion

aibrahim's avatar
aibrahim
Icon for Helper I rankHelper I
4 years ago
Solved

Help needed: Carry over balance from previous month

I'm having difficulty getting the below done and I really appreciate any help here. Here's what I'm trying to achieve:    I have a row data that includes date, time spent (hours), monthly allowance...
  • v-kkf-msft's avatar
    4 years ago

    Hi aibrahim ,

     

    Please create a Calendar table and these measures.

     

    Credit / Bonus = 
    CALCULATE (
        SUM ( 'Log of Hours'[Time (Hours)] ),
        'Log of Hours'[Task] = "Credit"
    )
    Starting balance = 
    VAR PreMonth =
        CALCULATE (
            SUM ( 'monthly budget'[Allowance of Hours] )
                - SUM ( 'Log of Hours'[Time (Hours)] ) + [Credit / Bonus],
            PREVIOUSMONTH ( 'Calendar'[Date] )
        )
    RETURN
        IF (
            PreMonth >= 0,
            SUM ( 'monthly budget'[Allowance of Hours] ) + PreMonth,
            SUM ( 'monthly budget'[Allowance of Hours] )
        )
    Remaining Balance = [Starting balance] - SUM ( 'Log of Hours'[Time (Hours)] ) + [Credit / Bonus]

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.