Forum Discussion

KW123's avatar
KW123
Helper V
4 years ago
Solved

Subtracting two rows

Hi,  I am hoping someone can help.  I have a column with sales values and I need to create a DAX where I minus A from B to get C but then take C and minus it from B to get D.  Then D-B=E etc for t...
  • tamerj1's avatar
    4 years ago

    Hi KW123 
    Sorry it was too late yesterday I couldn't reply to you. Here is a sample file with the solution jnowing that you will retun back to me with more information that you've been hiding as usual ğŸ˜‰https://www.dropbox.com/t/lzKxh0DxLA056sy7

    Result = 
    VAR A = 1000
    VAR B = 10
    VAR CurrentIndex = SELECTEDVALUE ( Data[INDEX] )
    VAR MaxIndex = CALCULATE ( MAX ( Data[INDEX] ), ALLEXCEPT ( Data, Data[Day].[Month] ) )
    RETURN
        IF ( 
            CurrentIndex <> BLANK ( ),
            A - ( MaxIndex - CurrentIndex ) * B
        )



  • tamerj1's avatar
    tamerj1
    4 years ago

    KW123 

    What does YTD total need to be =
    VAR A = [Accounting goal calc-c]
    VAR B = [Daily Goal]
    VAR CurrentIndex =
        SELECTEDVALUE ( Dates[FD2] )
    VAR MaxIndex =
        CALCULATE ( MIN ( Dates[FD2] ), ALLEXCEPT ( Dates, Dates[Date] ) )
    RETURN
        IF (
            DAY ( SELECTEDVALUE ( Dates[Day] ) ) = 1
                && MONTH ( SELECTEDVALUE ( Dates[Day] ) ) = 1,
            0,
            IF ( CurrentIndex <> BLANK (), A + ( MaxIndex - CurrentIndex ) * B )
        )