Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dynamic Dax based on date filters

Hi,  I'm trying to create a dynamic table based on date selection as the below DAX, but the problem is in the output where the Difference appears on both dates , not as a total difference, does any...
  • tamerj1's avatar
    4 years ago

    Salam Anonymous 

    This will return the desired result under the 2nd date

    Difference =
    VAR PreviousDate =
        MAX ( 'last month GL summary'[MIS_DATE] ) - 1
    VAR CurrentDateValue =
        SUM ( 'last month GL summary'[USD_currency] )
    VAR PreviousDateValue =
        CALCULATE (
            SUM ( 'last month GL summary'[USD_currency] ),
            'last month GL summary'[MIS_DATE] = PreviousDate
        )
    RETURN
        CurrentDateValue - PreviousDateValue