4 Replies Latest reply on Oct 10, 2018 5:58 AM by meenu choudhary

# Create a formula that always looks at the second to last month in data

Hello. How can I create a filter and/or a formula that only looks at the second to last month and third to last month in a data set?

I want to always analyze the most recent COMPLETE month and then the month before it.

For example, I would like to see average price for September vs. August (right now)

• ###### 1. Re: Create a formula that always looks at the second to last month in data

Hello Alex,

Are you looking for this:

1. Current month = DATETRUNC('month',TODAY())

2. Last month = DATEADD('month',-1,[Current month])

3. 2nd last month = DATEADD('month',-2,[Current month])

4. avg sales for last month = AVG(if DATETRUNC('month',[Order Date])=[Last month] THEN [Sales] END)

5. avg sales for 2nd last month = AVG(if DATETRUNC('month',[Order Date])=[2nd last month] THEN [Sales] END)

1 of 1 people found this helpful
• ###### 2. Re: Create a formula that always looks at the second to last month in data

Hello Alex Martino