Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate difference between values in different columns

Hi,   I would like to build the Excel visualization (see screenshot) in PBI. I assume this is possible with a DAX measure? I've been playing around with some DAX functions and tried some solutions ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    az38 thank you for your proposal, but unfortunately it did not work out.

     

    Eventually I found the solution using the following measures:

    1. PreviousDate
    2. Amount previous date
    3. Diff with prev date
    4. Diff %
    PreviousDate = 
        VAR CurrentDate =
            SELECTEDVALUE ( 'Sheet1'[Date] )
        RETURN
            CALCULATE (
                MAX ( 'Sheet1'[Date] );
                ALLSELECTED ( Sheet1 );
                KEEPFILTERS ( Sheet1[Date] < CurrentDate )
            )
    Amount previous date = 
    VAR Prev = [PreviousDate]
    RETURN
    CALCULATE (
            [Total Amount];
            Sheet1[Date] = Prev
        )
    Diff with previous = 
    [Total Amount] - [Amount previous date]
    Diff % = 
        IF (
            ISBLANK ( [Diff with previous] );
            BLANK ();
            DIVIDE ( [Diff with previous]; [Amount previous date] ) * 100
        )