3 Replies Latest reply on Feb 15, 2018 1:33 AM by Michael Huynh

    Measures relative to dynamically selectable date periods

    Michael Huynh



      I am trying to have measures [sales] change dynamically with order dates that a user can set by parameter [from date] & [to date].


      I have managed to do this for the selected period, but I was wanting to do this using the previous period as well.


      I've made a calculated field Sales Previous Period:


      IF ATTR([Order Date]) >= DATEADD('day',-[Date Difference],[From Date])

      AND ATTR([Order Date]) <= DATEADD('day',-[Date Difference], [To Date])

      THEN SUM([Sales]) END


      But this is not yielding results. I'm guessing it has something to do with my Date Difference calculation or using ATTR in the the above calculation for Order Date, to work around the aggregate and non-aggregate measure issue caused by using date difference.


      If anyone has experience with this or could help explain why my calculation is not working  it would be greatly appreciated. My workbook is attached.


      Many thanks!