8 Replies Latest reply on May 7, 2018 5:20 PM by Zhouyi Zhang

# getting the last month of last year

hey,

i am looking for a calculation to get the last month of last year.

could you help me!!

best regards

• ###### 1. Re: getting the last month of last year

Hi, Zineb

try something like

ZZ

• ###### 2. Re: getting the last month of last year

Hey Zhouyi,

it´s return the actual year 2018

• ###### 3. Re: getting the last month of last year

Some of it depends on how your data is set up, but this will find you December of "last year":

MAKEDATE(YEAR(TODAY())-1,12,1)

(That actually would create December 1, 2017 right now.)

Then do a calc that does this:

IF DATETRUNC('month',[Order Date]) = MAKEDATE(YEAR(TODAY())-1,12,1) then [Sales] END

What that calc will do is grab [Sales] for all rows in December of last year. (All other rows will have null.)  Then you can use SUM([My Calc]) to get the sum of sales in December of last year.

1 of 1 people found this helpful
• ###### 4. Re: getting the last month of last year

First create calculated field with name "max Date" and use formaula "MAX(Date)"

Then again create calculated filed and use DATEPART('month', Previous Calculated Field)

It'll give you last month of last year.

Thanks

Suman

• ###### 5. Re: getting the last month of last year

Hey Suman,

I don´t find the function makedate. it´sreturn a error.

Best Regards

• ###### 6. Re: getting the last month of last year

where you saw make date..?

1.) I have mentioned "Max(Date)" and put it in one calculated field. suppose name of this field is "Maximumdate"

2.) now create one more calculation--> DATEPART('month', Maximumdate)

That's it.

• ###### 7. Re: getting the last month of last year

Ugh.  I think some data sources don't allow it.

It's just a convenient function to make a date. You can do other ways to get it.  Try this instead:

DATETRUNC('year',TODAY() )  (this will truncate to January 1 of this year.)

DATETRUNC('year',TODAY() )-1  (this will subtract one day, to Dec 31 of last year)

DATETRUNC('month', DATETRUNC('year',TODAY() )-1)  (This will generate December 1 of last year.)

That final syntax is what you want to use in place if the MAKEDATE I suggested.

• ###### 8. Re: getting the last month of last year

Hi, Zineb

You need to format the result as month year format

ZZ