Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Adding a start value

Good afternoon to you all.

 

I have a waterfall chart and I want to add a starting value through DAX. My point is to add a given bank balance (which is in another table) to a bank movement account. I created the following DAX:

Test =
Var first_date = min(Tabela_Pagamentos[Date])
Return
If(Tabela_Pagamentos[Date]=first_date,Tabela_Pagamentos[Amount]+last_value,Tabela_Pagamentos[Amount]).
 
The problem here is that I have several movements on the first date, and it is summing them all. I only want to add the last_value to the first of them, like if it is a beggining balance. 
Can someone help me figuring out what I'm doing wrong? Is this the best way to solve my problem?
 
Thank you

 

2 Replies

  • You cannot add a row to a DAX table (at least not to an existing one).  You need to add that row in Power Query, or in your data source.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    My sample data is this.

    DateAmountAccount ID

    1/1/2020501
    5/4/2020552
    4/16/2020563
    2/1/2020511

     

    last_valueAccount ID

    51
    32
    43

     

    Then you may try this measure. The ALLEXPECT removes all context filters in the table except filters that have been applied to the specified columns.

    Measure =
    IF (
        MAX ( 'Tabela_Pagamentos'[Date] )
            = CALCULATE (
                MIN ( 'Tabela_Pagamentos'[Date] ),
                ALLEXCEPT ( Tabela_Pagamentos, Tabela_Pagamentos[Account ID] )
            ),
        MAX ( 'Tabela_Pagamentos'[Amount] ) + MAX ( 'Table (2)'[last_value] ),
        MAX ( 'Tabela_Pagamentos'[Amount] )
    )

     

    If this is not the result you want, please provide some sample data or detailed screenshots, remember to protect your sensitive information.

     

     

     

    Best Regards,

    Stephen Tao

     

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