5 Replies Latest reply on Apr 21, 2017 5:19 AM by Y Mani

# MTD Calculation

Hi,

I have tried using YTD and MTD Calculation as below, but MTD doesn't work

IF [Order Date] <= TODAY()

AND DATEDIFF('month',[Order Date],Today())= 0 THEN [Sales] END

IF [Order Date] <= TODAY()

AND DATEDIFF('month',[Order Date],Today())= 0 THEN [Sales] END.

Please can any one help me on this

Thanks

• ###### 1. Re: MTD Calculation

You need to do these as LOD calculations at the table level.

MTD

{Fixed: Sum(

IF [Order Date] <= TODAY()

AND DATEDIFF('month',[Order Date],Today())= 0 THEN [Sales] END)}

YTD

{Fixed: Sum(

IF [Order Date] <= TODAY()

AND DATEDIFF('year',[Order Date],Today())= 0 THEN [Sales] END)}

You should also be able to do table calculations to give similar results.

• ###### 2. Re: MTD Calculation

Hi Brain,

Thanks for the update.

But still I am getting the same issue.Please see the screen shot attached.

• ###### 3. Re: MTD Calculation

HI Mani,

Just a quick q. Since i can see you are using Sample super store DB, i dont see data for 2017, so your today() should fail.

Not sure how you can see blue data, probably a upload of workbook can help.

Regards,

Saumya Shetty

• ###### 4. Re: MTD Calculation

good shout on the TODAY() function... will also depend on the 'system time'

this should work - although you'll need to swap to your fields

IF [your date] <= today() AND DATEDIFF('month',[your date],today())= 0 THEN [sales] END

source: Time periods in Tableau

Cheers

Mark

• ###### 5. Re: MTD Calculation

Thanks Mark