0
votes

Original post - https://community.tableau.com/thread/206909

I have a report in which I have sales per month in the column and commodities in the row. The data show actual sales and future estimates for each month. enter image description here

Need to calculate Year-To-Date (YTD) total for 2016 (from Jan to Previous month) and have it in a single column at the end of the actual values.

I already created a calculated field - YTD

IF 
   YEAR([DATE]) = YEAR(NOW())
AND
   MONTH([DATE])< MONTH(NOW())
THEN
   [VALUE/UNIT]
ELSE
    0
END

But when I add to the view, it creates a another section for YTD with sum for each month till April.

Can someone please help me in how to achieve this in Tableau?

1
That isn't Oracle syntax. Is Tableau translating that, or are you actually using a different DBMS?Alex Poole
That's Tableau calculated field. I'm using oracle for connectionptomar
Can someone please help me here?ptomar

1 Answers

0
votes

There are couple of ways to achieve this view in Tableau 1. To create calculated field for each Month and YTD and add measure names in Row & Measure values in Text 2. Make union of 2 queries - one that select all the correct values & second that have YTD calculation in month column. Then use pivot it