Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DATEADD not working in Matrix

I created a measure that shows revenue from the 12 months before the last 12 months using DATEADD function.  I put it in a MATRIX and it works fine when there are no row or column headings added to t...
  • v-gizhi-msft's avatar
    6 years ago

    Hi,

     

    According to your description, i create a sample to test:

    Then create a date slicer table:

    Date Slicer = DISTINCT(SELECTCOLUMNS('Table',"Date",'Table'[Date]))

    Then try this measure:

    Measure = 
    var a = SELECTEDVALUE('Date Slicer'[Date])
    return
    CALCULATE(SUM('Table'[accrual_revenue]),DATESBETWEEN('Table'[Date],DATE(YEAR(a)-2,MONTH(a),DAY(a)),DATE(YEAR(a)-1,MONTH(a),DAY(a))))

    When choosing one date in date slicer, the result shows the total revenue from the 12 months before the last 12 months based on the date selected:

    Tips: In this case, i add a defined filter to the table visual to show the result more obviously.

    Here is my test pbix file:

    pbix 

    Hope this can help.

     

    Best Regards,

    Giotto Zhi