8 Replies Latest reply on Jun 14, 2018 11:41 AM by Nathalia Alvarenga

# How to get total sum of previous year results YTD in the Title of the Dashboard?

I need to add in the title of dashboard a dynamic total sum of Cost of Delay from the previous year YTD without impacting the current information. At the moment, I have the sum for 2018 YTD (from January until May). But I need the same period result for 2017.

I have calculated the 2018 as below:

TOTAL(SUM(IIF([Year]=2018, [Cost of Delay (USD)],0)))

But I cant seem to find the calculation for 2017, the closest I found was the one below:

TOTAL(SUM(IIF([Year]=2017, [Cost of Delay (USD)-18],0)))

I have tried the suggestions on different posts but it doesn't seems to work as well

I have managed to get the results as table calculation but I really need the formula behind the result. Is there a way to figure out how tableau is calculating the results for 2017?

• ###### 1. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

Hi Nathalia,

IF year( DATEADD('year',1, [Order Date])) =

year(

{FIXED : MAX([Order Date])})

then [Sales]

END

Please swap the order date to your date field, and also sales with the value you're using.

Then drag this calculated field into detail, then double click on title and you should be able to add it:

If you want the 2017 YTD where you compare the maximum date with the max date in 2018, you can use this calculation:

IF year( DATEADD('year',1, [Order Date])) =

year(

{FIXED : MAX([Order Date])})

and

DATETRUNC('day', {FIXED : MAX([Order Date])}) >  DATETRUNC('day', DATEADD('year',1, [Order Date]))

then [Sales]

END

Alternatively you can use today's date:

IF year( DATEADD('year',1, [Order Date])) =

year(

TODAY())

and

DATETRUNC('day', TODAY()) >  DATETRUNC('day', DATEADD('year',1, [Order Date]))

then [Sales]

END

I have attached the workbook as well so you can review.

Thanks,

Mavis

• ###### 2. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

This would Return Data for 2017 YTD

• ###### 3. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

HI Nathalia

Thanks,

Shin

• ###### 4. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

Hello Mavis,

Thanks for the suggestions but all the calculations are giving me the single sum of each month instead of the total sum of the period 2017 (Jan-May).

Please, see below how it worked out for me.

So, basically in the title it is showing the value for Dec 2017 to May 2017. But what I need is the sum of 2017 (Jan until May).

Does anything comes to your mind?

• ###### 5. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

HI Nathalia

Thanks,

Shin

• ###### 6. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

Hello Deepak,

Thanks for your suggestion but it is giving me results as below:

It shows me the results from May 2017 and June 2017, but what I need is the sum for 2017 (Jan-May). Anything else come to your mind?

• ###### 7. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

Hi Nathalia,

I don't understand quite what's going on... Our calculations only give you the one value.

So why is your title giving you a range of 560k - 639k?

Can you please provide us with a workbook?

Also, it looks as if your view has been filtered down to just May 2017 - May 2018, so that's another reason why you're not seeing the values from January 2017-April 2017 - because they've been filtered out.

Thanks,

Mavis

• ###### 8. Re: How to get total sum of previous year results YTD in the Title of the Dashboard?

Hello Mavis,

I had to do a separate calculation for total sum of the individual values and now it is working fine in the title.

You spot on well, the filters are also a problem.

Now that the calculation is working, is it possible to have the title independent from the filters? Basically, I don't want the filters to impact the calculation.

Not sure how this is possible...