2 Replies Latest reply on Dec 1, 2015 10:14 PM by Tableau kumar

# Calculate YTD Sales from Actual & Goal

I have two reports - actual revenue and revenue goal in long format. One lay on top of another. The first column will say report - actual or report - goal. Each is broken down by month, year, and target amount.

I want to calculate (one number) % of achieved revenue against revenue goal - to date. I don't have Nov or Dec actual revenue data yet, as the year has still not ended. It is considered unfair to measure 10 month's performance against 12 month's goal.

To avoid summing up the months where revenue data is not available, I created a seven step calculation:

1. Created a calculated field on monthly recognized revenue:
If report = recognized revenue, sum(amount)

2. Created a calc on monthly goal:
If report = revenue goal, sum(amount)

3. I created a filter to find out until which month do I have actual revenue data (typically a month or two before today's month, but no guarantee)

Filter: Sum(recognized revenue)>0

4: Running Sum of Recognized Revenue along Month

5: Running Sum of Revenue Goal along Month

6: Create index ('Position') using Last() to order my months to be included

7: Create a 'lookup function' to get the final percentage (green number in heading):

If position = 0, Sum(Running Sum of Recognized Revenue)/Sum(Running Sum of Revenue Goal)

That sounds like an awful lot of steps to get one number. There has to be a much more efficient way - Like a combination of if statements, fixed, include and exclude...

See the attached screen shot-

I present my puzzle. If anyone has a better solution, I'd greatly appreciate hearing about it.

• ###### 1. Re: Calculate YTD Sales from Actual & Goal

Hey Christina,

I'm sure some of our users could help you out but for such an in-depth question, a packaged workbook with sample data would be extremely useful. if you have sensitive data, I would check out Anonymize your Tableau Package Data for Sharing.

-Diego

• ###### 2. Re: Calculate YTD Sales from Actual & Goal

Even you don't have for NOV, DEC months, we can create YTD Calculations like Below,

if year([Order_Date])= year(today()) and

month([Order_Date])= month(today())

and

([Order_Date])<= (today())

then ([Sales]) end