Tableau desktop average line granularity error - average

[14 day sales trend,split by student type][1]
I was trying to plot an average line for the sales over the past 14 days. I have used average line in analytics pane for the entire table. And I have made bar chart to stacked bar chart by splitting the sales on each day with old/new student types. The average line was at ~470 when I tried without adding student type to "color" in marks card. The average line moved to 235 when I have added student type to "color" however the tooltip is showing ~470. The granularity level tableau taking is the student type but I need it at the day level. What change should I make to bring back the average line to the correct value i.e., 470 showing the student type details too.?

Two points:
As you stated, you have configured the average line to be calculated across the whole table, which should result in the average line calculation ignoring any more granular levels of detail. Since your line is moving as you add more dimensions to the view, this behavior indicates that you may have configured your average line to display AVG(Sales) Average, instead of SUM(Sales) Average. Right-click the average line and choose Edit. Then, change the Value selectors to SUM(Sales) Average.
When you add an average line from the analytics pane, this metric does not automatically also get added to the tooltip. So, comparing the value of the average line to what you have in the tooltip is likely not a valid, "apples to apples" comparison. Check to see if you may have added AVG(Sales) somewhere else in the view in addition to adding the average line from the analytics pane.

Related

Tableau: Need to add Total Average to Dual Line and bar chart

Example
Trying to make that average line show by date total average of Conversion against selected Supervisor in filter.
Trying to add Total Average of Conversion Sales to a chart with Conversion Sales shown as Line, and # of Coaching, # of Calls as bar.
In Columns I have Date.
In Rows I have Measure Values (Coaching , Calls), Average Conversion.
The Manager will select his supervisors in a filter to see data, I want manager to be able to see Average Conversion of all Supervisors even with selecting certain Supervisors.

Side-by-side bar chart: One with the current filtered selection and one for total

I calculate the percent of total number of active customers for each SalesOwner in one of my Workbook sheets:
As you see, I have also added the SalesOwner as a filter.
The calculated field (segment_active_members) is computed using the following formula:
COUNTD(wk_customer)/ SUM({FIXED : COUNTD([wk_customer])})
What I want to do is create a side-by-side bar chart where upon filtering one of SalesOwners, I am able to compare it with the total (100%). So if I filter the above sheet by SalesOwner X which takes 5% of total. I'd like to see only two bars with one having 5% of the other one's length.
So I add another calculated filed to the above scenario where a fixed total is calculated:
SUM({FIXED : COUNTD([wk_customer])}
We will have a new column in the above picture with a fixed value of 100% for all rows.
I get what I want when my filter is on "All".
But as soon as I select a single filter (SalesOwner), my first percentage is also changed into 100% and I can never compare it to total.
How can I show the percentage against total for single segments?
This could be one of the solution:
Change the calculation of segment_active_members as follows
SUM({FIXED [Sales Owner]: COUNTD([wk_customer])})/SUM({COUNTD([wk_customer])})
Remove the table calculation for segment_active_members in the Measure Values shelf
You'll see that you are able to filter it down without any problem now
Cheers!

Tableau average line on chart of averages

I have a bar plot with average values for some dimensions, let's say: weekdays. Now I want to put an average line on it - I use Analytics > Average Line. The line I get doesn't show the average for all data examples though, but the average counted from the aggregated values on the plot (avg from 7 values).
Can I get somehow the other one?
Put whatever your [Value] field is called on the Detail shelf. Then double click on it to edit it on the shelf
Change the expression to Total(Avg([Value])) where Value is the field you are displaying
Use this field for your average line, Read about Total() in the documentation. You may also need to edit the table calc addressing and partitioning characteristics to scope your total as desired (although the default settings often work) Read about Table Calcs in the on-line help for more info

Require minimum number of data points before plotting a point in Tableau

Can I cause Tableau to require a certain number of underlying data points before plotting a point on the graph?
For example, here's a graph showing average moods over the course of the day on Tuesdays:
There's nothing uniquely awful about midnight on Tuesdays, it's just that there's only one data point for that particular time, and it's an outlier. Is it possible to have the graph show midnight as missing unless there are more than (for example) three different records from midnight being averaged together?
You could define an aggregate calculated field, called say avg_mood as:
if count(Mood) >= 3 then avg(Mood) end
Since the aggregation is hard coded into the calculation, Tableau will display AGG(avg_mood) for the field on any shelves you use it on, rather than letting you toggle the aggregation outside the formula as it will for other measures.
Note, there is no else branch, so the calculation will evaluate to null if there are less than three non-null Moods in a partition of data rows (based on the dimensions)
You can control how null values are displayed in a line chart. On the format pane, select the field in question from the pull down menu by the word Fields at the top right of the format pane, then select the Pane tab, then at the bottom of the format pane, adjust the Mark settings in the Special value section.

Adding Reference Line for Weighted Average in Tableau

I've got a bar chart with three months worth of data. Each column in the chart is one month's data showing the percentage of Rows that met a certain criterion for that month. In the first month, 100% of 2 rows meet the measure. In the second month, 24.2% of 641 rows meet the measure. In the 3rd month, 28.3% of 1004 rows meet the measure. My reference line which is supposed to show the average across the entire time-frame is showing 50.8%, the simple average (i.e. [100+24.2+28.3]/3) instead of the weighted average (i.e. [100*2+641*24.2+1004*28.3]/[2+641+1004]).
In the rows shelf, I have a measure called "% that meet the criterion", this is defined as SUM([Criterion])/SUM([NUMBER OF RECORDS])
The criterion measure is 1 for any record that qualifies and null for any that do not qualify.
If I go to Analysis >> Totals >> Show Row Grand Totals, a 4th bar is added, and that bar shows the correct weighted average of the other three bars (26.8%), but I really want this to be shown as a reference line instead of having an extra bar on the chart. (Adding the Grand Total bar also drops the reference line down to 44.8%, which is the simple average of the 4 bars now shown on the chart--I can't think of a less useful piece of information than that).
How can I add the weighted average as a reference line?
Instead of using 'Average' as your aggregation, try using 'Total' instead in the Edit Reference Line dialogue window.
I have to say it's a bit counter-intuitive, but this is what the Tableau online help has to say about it:
http://onlinehelp.tableau.com/current/pro/online/mac/en-us/reflines_addlines.html
Total - places a line at the aggregate of all the values in either the cell, pane, or the entire view. This option is particularly useful when computing a weighted average rather than an average of averages. It is also useful when working with a calculation with a custom aggregation. The total is computed using the underlying data and behaves the same as selecting one of the totals option the Analysis menu.
If you are using Tableau 9, you can make second calculated field using an LOD expression
{ SUM([Criterion]) / SUM([NUMBER OF RECORDS]) }
This will calculate the ratio for the entire data set after applying context and data source filters, without partitioning the data by any of the other dimensions in your view (such as month in your case)
If you place that new field on the detail shelf then you can use it to create a reference line.
There are other ways to generate a weighted average, but this is probably the simplest in your case.