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

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!

Related

Power Bi Clustered Column Chart to show % or row total

I am using Power Bi to produce several reports, one of it is the NPS score for support. However, I am coming across an issue with the clustered column chart. It is showing the value against the total number rather than for each row.
What I want to see if the following (within Excel),
The NPS score is shown as a percentage for each week.
e.g. Week 3 has the Promoter at 95.5% and Detractor at 4.5%
However, when using Power Bi, I am shown the following, which is a Percentage of the grand total, instead of each week.
Using a Matrix, I could see the following as total numbers.
I can copy this Matrix and show it as a Percentage of each Row, which is also correctly showing the results.
I have the dates already set up using a feeder table to allow me to get the week number etc from a date within the main raw data, so they sort in the correct order..
My Chart is using the following table entries
Cal Week and WeekNo are both from the feeder table (Fiscal)
Net Promoter and Count of Case Num are from the RawData table.
How can I get the chart to show the percentages per week instead of the total?
I am also planning to use slicers to filter down further, for example, Regions (which are in the RawData).
I believe I will need to add an extra column to the RawData, but no idea what to put in it and then how to use that in the chart, and still allow it to slice.
Any help would be greatly appreciated.
Thanks
DD

Tableau desktop average line granularity error

[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.

Grand Total for discrete column

I am new to tableau and trying to show grand total for discrete columns however it shows blank. Is there a workaround. Can one total for discrete columns?
Here's the snapshot:
I tried to follow tableaus notes and removed the discrete columns and double clicked it , however it becomes continuos and tries to aggregate it. Is there a work around?
Please help
You can't grand total a discrete column. It either has to be continuous OR you create a WINDOW_SUM calculation to calculate the grand total, then put the total in the Title area instead of within the table.
An easy way is to move your discrete measure from the Rows shelf to the Text shelf and then make it continuous. If you have multiple measures, you can get a similar effect with the placeholder fields Measure Names and Measure Values

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

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.