Order of Execution in Tableau:
Computed in the database:
1. Context filters
2. Top N and conditional filters
3. Regular quick filters
Computed in Tableau:
4. Table calculations are computed
5. Table calculation filters are applied
6. Reference lines
This means that for a Top N chart that needs to display the Top 10 Sales per State, Average Sales of Top 10 States and the Average Total Sales all States, you have to make sure that the average all states needs to be computed before the filter is applied, you have to use the Window_AVG and add it to dual axis as line. The Top N condition needs to be applied after the Window_Avg calculation. The Windows_AVG is calculated in step 4, so the TOP N needs to be in step 5 or 6. The ‘Normal’ way of calculating TOP N is on database and cannot be used that leaves a table calculation filter. Add the Sales measure to the filter, add a quick table calculation Rank, and then modify this to run along State and keep the sorting in Descending order.
In case you need a filled area chart on Percent of Sales with possible filter option, this execution path means you need to make sure you create a table calculation on your filter dimension else the % of Total will be 100% instead of the correct share of total. You could use e.g. a calculated field like Region select: lookup(Max([Region]),0) and then filter on this new field.