I've excel datasource (as greyed below) and I want to show 4 calculated fields (CF) as (red highlighted) for 4 "Team" as highlighted in yellow. Output required is green highlighted.

Output I got as shown in image:

Problems faced:

1. Not able to find right answer for Forecast and GAP. Formuales used are below:
2. How to represent ONLY (# of Sales) monthwise but display all 4 CFs at QUARTER levels as shown in the green above.

```# of sales = COUNT([Productname])

Days Passed = DAY([Sale Date])-day(TODAY())

Forecast = (([#ofSales]))/(avg([DaysPassed]))*avg([TotalDays])

SalesTarget (copy) = { FIXED [Team], quarter([Sale Date])=1 : avg([SalesTarget])}

GAP = (sum([SalesTarget (copy)]))-[Forecast]

TotalDays = if quarter([Sale Date])=1 then 91
ELSEIF quarter([Sale Date])=2 then 92
ELSEIF quarter([Sale Date])=3 then 92
ELSEIF quarter([Sale Date])=4 then 92 end

SalesTarget = if [Team]="USA Small" and quarter([Sale Date])=1 then 10
ELSEIF [Team]="USA Big" and quarter([Sale Date])=1 then 5
ELSEIF [Team]="UK Small" and quarter([Sale Date])=1 then 3
ELSEIF [Team]="UK Big" and quarter([Sale Date])=1 then 3
END

SalesTarget (copy) = { FIXED [Team], quarter([Sale Date])=1 : avg([SalesTarget])}
```

I've tried multiple workarounds but couldn't find solution. I can't attach any file in Stack Overflow. So added just few code samples, I'd tried out of many.

Mar 29, 2022 in Tableau 426 views

## 1 answer to this question.

Please refer to the following steps for reference.

I hope this helps you

Master data visualization with our Tableau Training and unlock powerful insights from your data.

• 9,060 points

## Displaying Aggregations across bar chart in Tableau

Hi Sindhu, 1.You can use average lines to ...READ MORE

## Error Running python (forecasting) in Tableau

I'm quite new to this system as ...READ MORE

## How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

## How to exclude weekend (Sunday only) to DATEDIFF in Tableau?

To exclude Sundays from the DATEDIFF calculation ...READ MORE

## Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

## How to calculate profit when cost and revenue are in same column?

You can create the following calculated fields: Profit: SUM(IIF([account_category] ...READ MORE