Forum Discussion

GokilaRaviraj's avatar
GokilaRaviraj
Icon for Helper II rankHelper II
1 year ago
Solved

Calculating closing balance

Hi  dufoq3 , I have been struggling with creating a DAX code for this.  I have given below sample input tables This is NetCashFlow table which is a calculated table Company Month Value A ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi GokilaRaviraj 

     

    Thanks for the reply from 123abc .

     

    First of all, I want to confirm your request with you. Why is the value of B in October 170? Is it the value of A in December plus the value of B in October in the OB table?

     

    The following test is for your reference.

     

    Create a calculated column in each of the two tables, and then create a relationship between the two tables based on this column.

     

     

     

     

    Create a measure as follows

    Measure = 
    VAR _sumN = CALCULATE(SUM([Value]), FILTER(ALL(NetCashFlow), 'NetCashFlow'[Month] <= MAX([Month]) && [Company] = MAX([Company])))
    VAR _sumOB = CALCULATE(SUM(OpeningBalance[Value]), FILTER(ALL(OpeningBalance), [Month] <= MAX([Month]) && [Company] = MAX([Company])))
    RETURN
    _sumN + _sumOB

     

    Output:

     

    Best Regards,
    Yulia Xu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.