10 Replies Latest reply on Oct 31, 2018 10:58 AM by satya kanth achanta tishan

# Latest Month

I need to calculate "Latest Month Units" but for that the formula is :

 IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=0 THEN [Units] END

But in my source Sheet (Excel) I have Year, Month and Quarter columns I don't have Order Date.

How can I calculate Latest Month Units ?

Thank You

• ###### 1. Re: Latest Month

Year(Today())=Year and Month(Today())=Month

Drag it to Filter for Latest Month by Setting as TRUE

• ###### 2. Re: Latest Month

Deepak -- That assumes the data source has data in the current month.  If so, your approach would work.

Otherwise Satya should make a date field from the three integer columns.

I'm not sure if EXCEL supports MAKEDATE().  If so, that's the easiest thing.  Otherwise just build a date value from the three components.

• ###### 3. Re: Latest Month

DATE(STR([Month])+"/"+STR([Day])+"/"+STR([YEAR]))

Then use that calc (which will be a date field) in place of [Order Date] in the DATEDIFF calc.

• ###### 4. Re: Latest Month

I deleted the duplicate copy of this thread.

• ###### 5. Re: Latest Month

It gives error cant compare integer and string values

On Wed, Oct 31, 2018 at 1:39 PM Deepak Rai <tableaucommunity@tableau.com>

• ###### 6. Re: Latest Month

Year(Today())=INT(Year) and Month(Today())=INT(Month)

• ###### 7. Re: Latest Month

I don’t have day I have year and month only

On Wed, Oct 31, 2018 at 1:38 PM Joe Oppelt <tableaucommunity@tableau.com>

• ###### 8. Re: Latest Month

satya kanth achanta tishan wrote:

I don’t have day I have year and month only

OK, then just insert 1 for the DAY part.

• ###### 9. Re: Latest Month

And if your fields are string values already, you don't have to do the STR() function on them.

• ###### 10. Re: Latest Month

Ok thank you

On Wed, Oct 31, 2018 at 1:54 PM Joe Oppelt <tableaucommunity@tableau.com>