Forum Discussion

Edgar_massa's avatar
Edgar_massa
Helper II
3 years ago
Solved

balance calculation

Good night guys

Here's the thing, I have a bank balance table that brings me the balance on the 1st of each month, and I have a fact table containing my realized balance (income - expense).

I need the print table just below

 

 

to calculate the simple sum of the balance made with the bank balance (- 1,406,019.86) + 7,738,756.96 which gives 6,332,737.10 on day 1, and this result of 6,332,737.10 is calculated on day 2 and so on.

Thanks

  • Good afternoon

    I managed to solve it as follows

     

        VAR Saldo1 = [Saldo Realizado] + [Saldo de Contas]

        VAR Calc =
        CALCULATE(
            [Saldo Realizado] + [Saldo de Contas],
            FILTER(
                ALLSELECTED(
                    dim_Calendario),
                    [Saldo Realizado] + Saldo1 ),
                   
                    dim_Calendario[Data] <= MAX(dim_Calendario[Data])
        )
     

     

     
    Very similar to your solution danextian 
     
    Very Thanks
     

3 Replies

  • Hi Edgar_massa ,

    If i undestand your use case right, you're getting the running balance of Saldo Realizado and add it to  Saldo Bancario. Try these measures:

    =
    CALCULATE (
        [Saldo Realizado],
        FILTER ( ALL ( datestable ), datestable[date] <= MAX ( datestable[date] ) )
    ) + [Saldo Bancario]
    
    =
    CALCULATE (
        [Saldo Realizado],
        FILTER (
            ALLEXCEPT ( datestable, datestable[month] ),
            datestable[date] <= MAX ( datestable[date] )
        )
    ) + [Saldo Bancario]
    
    =
    CALCULATE ( [Saldo Realizado], DATESMTD ( datestable[month] ) ) + [Saldo Bancario]

     

    If Saldo Realizado and Saldo Bancario are not measures, replace them with something like SUM( table[Saldo Realizado ] ) and SUM( table[Saldo Bancario] ).

  • Hi,

    Share data in a format that can be pasted in an MS Excel file and show the expected result for a few line items.  Also, if possible, please translate the column names of the Tables in English.

  • Good afternoon

    I managed to solve it as follows

     

        VAR Saldo1 = [Saldo Realizado] + [Saldo de Contas]

        VAR Calc =
        CALCULATE(
            [Saldo Realizado] + [Saldo de Contas],
            FILTER(
                ALLSELECTED(
                    dim_Calendario),
                    [Saldo Realizado] + Saldo1 ),
                   
                    dim_Calendario[Data] <= MAX(dim_Calendario[Data])
        )
     

     

     
    Very similar to your solution danextian 
     
    Very Thanks