Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

ENDING BALANCE AS BEGINNING BALANCE NEXT DAY

  Help me create the DAX. I want to display the ending balance on Sep 22, 2025 as the beginning balance on the next day. Beginning balance on Sep 23, should be 9,979,154,330.51. Ending bala...
  • Khashayar's avatar
    1 year ago

    Hi Anonymous , you want:

    • Beginning Balance of each date = Ending Balance of the previous date
    • Ending Balance = Beginning Balance + Total Receipt – Total Payment

     

    Step 1 — Calculate Ending Balance

    You can use this calculated column (if you already have the Beginning Balance):

     

    Ending Balance =

    [Beginning Balance] + [Total Receipt] - [Total Payment]

     

    Step 2 — Calculate Beginning Balance dynamically

    If you want to compute the Beginning Balance automatically from the previous day's Ending Balance, use this DAX:

     

    Beginning Balance =

    VAR CurrentDate = [Date]

    VAR PrevDate =

        CALCULATE(

            MAX('Table'[Date]),

            FILTER('Table', 'Table'[Date] < CurrentDate)

        )

    VAR PrevEnding =

        CALCULATE(

            MAX('Table'[Ending Balance]),

            FILTER('Table', 'Table'[Date] = PrevDate)

        )

    RETURN

    IF(

        ISBLANK(PrevEnding),

        [Beginning Balance],   // Keep first day's balance as starting point

        PrevEnding

    )

     

    Step 3 — Optional: Recalculate Ending Balance consistently

    To make it fully dynamic (so you don’t need to manually set Beginning Balance each day), use this:

     

    Ending Balance =

    VAR CurrentDate = [Date]

    VAR PrevDate =

        CALCULATE(

            MAX('Table'[Date]),

            FILTER('Table', 'Table'[Date] < CurrentDate)

        )

    VAR PrevEnding =

        CALCULATE(

            MAX('Table'[Ending Balance]),

            FILTER('Table', 'Table'[Date] = PrevDate)

        )

    VAR Beginning =

        IF(

            ISBLANK(PrevEnding),

            [Beginning Balance],

            PrevEnding

        )

    RETURN

    Beginning + [Total Receipt] - [Total Payment]

     

    Important Notes:

    1. Replace 'Table' with your actual table name.
    2. Make sure [Date] is a Date data type (not text).
    3. Sort your visuals by Date ascending.

     

    If this post helped resolve your issue, please mark it as the accepted solution to make it easier for others to find.

     

    Regards,

    Khashayar Yazdani | Microsoft MCT

    https://www.linkedin.com/in/khashayary/