Forum Discussion

gujralh's avatar
gujralh
Helper I
2 years ago
Solved

How to create the measure for getting the Value difference between 2 dates

Hi All   Please help me in creating the measure for getting the value difference between 2 dates i.e Existing date with last 7th date.   Here in below table values against each date is also a mea...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi gujralh ,

     

    Thank you for your reply.

     

    Please create the following two measures to show the value difference and % value difference for dates every seven days:

     

    Measure_Difference_7Days = 
    VAR CurrentDate = MAX('Table'[Date_ID])
    VAR PreviousDate = CurrentDate - 6
    VAR MeasureCurrent = [Measure1]
    VAR MeasurePrevious =
       CALCULATE(
           [Measure1],
           FILTER(
               ALL('Table'),
               'Table'[Date_ID] = PreviousDate
           )
       )
    RETURN
       IF(
           ISBLANK(MeasurePrevious),
           BLANK(),
           MeasureCurrent - MeasurePrevious
       )

     

     

    Measure_Difference_Percentage_7Days = 
    VAR CurrentDate = VALUE(MAX('Table'[Date_ID]))
    VAR PreviousDate = CurrentDate - 6
    VAR MeasureCurrent = [Measure1]
    VAR MeasurePrevious =
       CALCULATE(
           [Measure1],
           FILTER(
               ALL('Table'),
               VALUE('Table'[Date_ID]) = PreviousDate
           )
       )
    VAR MeasureDifference =
       IF(
           ISBLANK(MeasurePrevious),
           BLANK(),
           MeasureCurrent - MeasurePrevious
       )
    RETURN
           MeasureDifference / MeasurePrevious
    

     

     Result for your reference:

    Best regards,

    Joyce

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