Tableau filter values instead of aggregate - filtering

I have the following sample data
Origin A, A, A, A, A
Destination C, D, E, F, G
Distances 5, 6, 7, 8, 9
Revenue 20, 25, 40, 55, 60
What I want to do is filter out all destinations with distances 7 or greater and display the aggregated results in one row.
What I can do so far is get this table:
Origin: A, A
Destination: C, D
Revenue: 20, 25
What I want is to display the following table with the Origin and the Sum of the Revenue:
Origin: A, Revenue: 45
When I apply the filter on Distance, I set it to be At Most 6, which works when I have 'Destination' in the Columns field, but when I take 'Destination' out, then the filter applies itself to all the distances aggregated (35), which would then filter out everything.
How can I get the filter to filter on individual values instead of the aggregate?
Thanks for your help!

Right click the field (on the filter shelf), choose dimension (rather than measure). This will consider individual values of the field, rather than the aggregation (probably sum by default).
Not sure if this will solve your problem, as I didn't understand what you are trying to do. But this is one way to filter individual values rather than the aggregation.

There are several variations possible on the filter shelf that cause different effects, depending on whether the field is set to dimension or measure, and what options are selected on the various tabs of the filter panel, not to mention context filters.
In your specific case, you should simply be able to place the Distance field on the filter shelf to get a row level filter to on include data rows where the Distance value is <= 6

Related

Tableau How to evenly split a Ranking Table into two

I am trying to evenly split a ranking table into two.
I tried to create a calculated field using rank to divide the data into two groups.
The problem with this approach is that there are too many entries in the first column because they are tie with rank 1.
I don't want to break the tie but display evenly in both columns.
So, desired output will look like...
25 states with Rank 1 are displayed in column 1, and the rest 12 rank 1 states and the other states from rank 38 to 49 are displayed in column 2.
In order to split your rows within a specif number (say 25) you can't rely just on rank due to same values for multiple rows.
Even though your Rank calculated field must be shown in the chart, you can add another calculated field based on rank_unique which will provide you a progressive number for rows having the same value for the specified metric.
Just use the specified function:
RANK_UNIQUE(SUM([Value]),'desc')
And then use the calculated field as a filter to "split" the results as you need (in this example 1-4, 5-8).

Percentage of total changes on applying filter

I have a data table with three dimensions and one measure. For each row, I am trying to calculate the percentage of total (calculated by taking the sum of rows) using a calculated field.
As seen in the screenshot attached, For the column titles 'Dec-19' I want the values to be a percentage of current value / grand total (calculated at the bottom as 122,187)
Screenshot of DataTable:
So e.g. for the Column B value of 2000, the Dec-19 column should be (97/122,187) * 100 = 0.079.
I have achieved this by creating a calculated field with the formula: SUM (sales) / MAX ({EXCLUDE (Column B): Sum (sales}), where sales is the measure used in the datatable.
However, upon application of filter on column B, the percentage value changes. e.g. if I select the value 2000 in my filter for column B, I get the percentage as 100%. It seems as if the percentage is being calculated based on only the rows in the filter.
Since you haven't included any sample data, I created some sample data like this, hope this resemble yours.
Thereafter, I built a cross-tab view in tableau, somewhat like yours
If that is the scenario, use a calculated field, say CF like this, instead of yours
([Sales])/
{FIXED [Col1], DATETRUNC('month', [Col3]) : sum([Sales])}
Dragging it in the view
and thus, filtering won't affect your calculation

Tableau - Toggle between 2 measures by single select filter on one basic text grid

looking to have a basic text grid by month by product, and then have a single filter on only 2 of the measures. For example:
Measures Filter
------------------
[ ] Sales <-- only show this
[X] Quantity <-- and this as options
[ ] Interest (don't show in filter)
[ ] Fee ( don't show in filter)
JAN | FEB | MAR | APR | MAY | etc ...
products
ITEM1 x x x x x
ITEM2 x x x x x
ITEM3 x x x x x
So the user can basically toggle between Sales or Quantity, and whichever they click on will fill out the x by month.
I was able to get this to work for everything except only showing the 2 measures I want to filter for. It only shows all measures for me in the filter and I can't figure out how to hide them.
What I did was
Drag Date to columns
Drag Product and MeasureNames to Rows
Can someone please help me on getting this correct? Any help or guidance is appreciated!
This is not the correct use case of FILTERS. Filters are normally used to filter (read subset) the data (read rows). Say for example If your dataset has 1000 rows/records and you want some report/visual/aggregation on say 500 rows (based on some criteria of course) you have to filter the data. For selection of argument (user based) in some report/viz, etc. Parameters are used.
Your desired example output is also a perfect case of use of Parameters. You may proceed as follows-
Step-1 Create a parameter (say parameter 1) with values as SALES and QUANTITY.
Step-2 Create a calculated field (say CF1) with the following calculation
CASE [parameter 1]
WHEN 'SALES` THEN [sales]
WHEN 'Quantity' then [Quantity]
END
Note: It is assumed that your field/column names in dataset are sales and Quantity
Step-3 Build your view (Crosstab here) with
months on Columns shelf
products on rows shelf
CF1 on text in Marks card (alternatively just double click it)
Choose measure for aggregation of CF1 as desired (default will be sum)
Step-4 right click paramter 1 and click show parameter. (select desired measure for aggregation in crosstab)
VOILA your desired view is complete. Good luck.
There is another options to add to Anil's good suggestion. You can also use Measure Names as a filter. Hide all measures apart from those you want in the filter, then put Measure Names on the filter shelf.
However, this means you can't use the hidden measures from the data source elsewhere, which can be a deal breaker. Duplicating the data source is a way around that limitation.
But if you only want to show the 2 measures and are happy with single select, then choosing the measure by parameter is the better option, as Anil suggests.

Get average value of each (Sub) column

i would like to calculate the average of values of each "main" column, as shown in the picture (named as bundling column). Each bundling(main) column has 1 to N "sub columns" (which are values for a certain datetime). The bundling itself is variable, it changes for different filters.
How can i reference to these sub columns to get the sum/count and average of these? I thought of using the "Window average" function but i don't have an idea how to define the start/end offset parameters. Not sure if window average is the correct option.
Thank you very much
A level of detail (LOD) calculation will allow you to control at what level the aggregation occurs.
{INCLUDE [Agg(Bundling)]: AVG([Agg(Error Select)]}

Tableau count average from averages

There is some data:
A, B, C (where C = A/B)
10, 20, 0.5
10, 100, 0.1
There are two ways of counting the average C:
First is sum(A)/sum(B), that gives C equal 20/120=0.1666
This is Tableau: sum([A])/sum([B])
Second is avg(C), that gives C equal (0.5+0.1)/2=0.3
This is in Tableau: No Idea...
Both have different usages. I need the second one, but can't find a way to calculate it. Anything I try, I always get the first type.
You are correct. In your first method, tableau is calculating the calculated field C by summing values according to the dimensions you are partitioning on in your view.
In your second option, you need to tell tableau to calculate column C (or define a different column D) for every row of the data, no sums involved. Simply: [A]/[B].
Then when you AVG column C (or D) you will get the average of all A/B values, instead of SUM(A)/SUM(B). You can get the average of column D by using the built in tableau AVG function instead of doing it manually