3 Replies Latest reply on Jan 14, 2019 5:00 AM by Shinichiro Murakami

    Previous Month to Date Calculation

    varun kalra

      Hi

       

      I am looking to find number of orders (month to date) in the previous month of the selected/current month. I am using a calc. field to calculate previous month orders as :

       

      Previous month Orders (mtd):

       

      COUNTD(IF( DATEPART('day',[Order Date]) < DATEPART('day',TODAY()) AND YEAR([Order Date]) = [Current Year]

      AND MONTH([Order Date ]) = [Current Month]-1) then [OrderID] END)

       

      The above calculation works fine throughout the year but the problem arises with the first month of year change. For eg. if I select Jan 2019 the field as mentioned above does not give me Dec 2018 month to date orders.

       

      My 'Current Month' and 'Current Year' are parameters:

      Screen Shot 2019-01-13 at 22.43.01.png

       

      Is there any way I can solve the issue and still continue to use "Current Month' and 'Current Year' parameters?

       

      Attached is the workbook for reference.

       

      Thanks in advance

       

      VK