Forum Discussion

Rafael_Batista_'s avatar
Rafael_Batista_
Regular Visitor
2 years ago
Solved

Balance for Calculation for each entry in the Balance

Good Afternoon 

I need help calculating the balance of each value in my table I created a formula that calculates the balance according to the financial movement of the day But he does it by building up the day For example: If on 01/30/2024 I have 10 releases Instead of it calculating value by value in my balance It only shows the final value of the last release and I needed it to calculate value by value (I calculate what I say is Balance + Revenue or Balance - Expense)

Form Dax using: 

Balanço =
VAR date = MAX(CR[Vencimento])
var _value =
CALCULATE(
    [Diferença],
    FILTER(
        ALLSELECTED('CR'),
        CR[Vencimento] <= date))
 
RETURN
_value + [Saldo]

Meanings
[Diferença] =  Revenue - Expenses
[Saldo] = Balance


Tanks for you help 🙂
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Rafael_Batista_ ,

     

    I made simple samples and you can check the results below:

    Balance = var _Expense = MAX('Table'[Expense])
    RETURN IF(_Expense=BLANK(),MAX('Table'[Revenue]),-MAX('Table'[Expense]))
    
    Total = var _t = ADDCOLUMNS('Table',"TOTAL",SUMX(FILTER(ALL('Table'),[ID]<=EARLIER([ID])),[Balance]))
    RETURN MAXX(_t,[TOTAL])

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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

4 Replies


  • This is the result of the formula




    This is the expected result of launches on the same date 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Rafael_Batista_ ,

     

    I made simple samples and you can check the results below:

    Balance = var _Expense = MAX('Table'[Expense])
    RETURN IF(_Expense=BLANK(),MAX('Table'[Revenue]),-MAX('Table'[Expense]))
    
    Total = var _t = ADDCOLUMNS('Table',"TOTAL",SUMX(FILTER(ALL('Table'),[ID]<=EARLIER([ID])),[Balance]))
    RETURN MAXX(_t,[TOTAL])

     

    An attachment for your reference. Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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

    • Rafael_Batista_'s avatar
      Rafael_Batista_
      Regular Visitor

      Thaks for your answer, but for me isn't work because [ID]
      I haven't this Data

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Rafael_Batista_ ,

         

        This ID column is not required, you can replace it with a date column.

         

        Hope it helps!

         

        Best regards,
        Community Support Team_ Scott Chang

         

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