How to filter one source by clicking and filtering a bar chart from another source in Tableau? - tableau-api

I used an Apriori algorithm to view the frequent relationships in the dataset and I want to do a dashboard to better visualize this data but I don't know how to do this filter.
This is the bar chart that I created to show the support (amount of times something happend) and the confidence (probability of B happening given A) of these associations:
Apriori Chart
Next to it on the dashboard, I'll have a table with the full dataset used in this Apriori analysis where I have more information such as ID, Income, Hours Worked, etc:
Table from different data source
How can I create this relationship? The two data sources don't have a column in common that I can use for that.
I would need some way to:
Split the values in the antecedents columns by comma and filter only those columns with value equal to 1 in the other dataset
**Dataset A**
'Age Range <=30, Joblevel 1, Maritalstatus Single'
->
'Age Range <=30'
'Joblevel 1'
'Maritalstatus Single'
**Dataset B**
'Age Range <=30' == 1
'Joblevel 1' == 1
'Maritalstatus Single' == 1
Clicking this would filter the table next to it
Is there any way I can do this in Tableau?
You can download the tbwx i used in this example here https://community.tableau.com/servlet/JiveServlet/download/1083124-384949/Apriori.twbx
Thanks in advance for the help!

I am not able to check your twbx on the machine I'm using but I think you should be able to do this. The fields in the 2 data sources need to match so manipulate the data sources the make this happen.
For data source 1 there's a function SPLIT which will mean you are able to split the comma separated string to 3 fields.
Putting those 3 fields to the Detail shelf of your bar chart (or even Rows and hiding the header) will mean you can use them in an action filter.
Your second data source is a cross tab - post pivot. You should be able to pivot this data source. Highlight the measures and pivot them. This will give you the field Pivot Field Names and Pivot Field Values.
You only want to keep those with a value of 1 so create a calculated field
[Lookup1]: IF [Pivot Field Values] = 1 THEN [Pivot Field Names] END
Duplicate this field twice so you have Lookup1, Lookup2 and Lookup 3.
Then you should be able to action filter the table.
In the action filter set it up so SplitField1 = Lookup1, SplitField2 = Lookup2, etc.
Fingers crossed this works, I haven't been able to test so I am pulling it out of my head.

Related

Tableau - add row without making it a subset of previous row

I want to add rows to a Tableau text table without making the row a subset of the previous row. Using the example below, I want values for teams and status to display on separate rows rather than status appearing as a subset of team. I also want to add a team filter so that if I filter on team blue, values for green row are zero and status values update . Is this possible? I tried creating separate worksheets but keeping things aligned is problematic.
Example Data:
Desired text table:
What I don't want:
Select both the fields(team, status) simultaneously then right click and go to Transform > Pivot.
Then 2 Dimensions will be created. Drag the Pivot Field Values on to Rows section
and Year on to Columns section and keep Year in Discrete format.
Then drag Number of Records on to value field section.
Before Pivot:
After Pivot and final viz:

Counting the number each element in a comma seperated column in Tableau

I am new to using Tableau.I want to count the number of times each genre appears in the data set.
In the data set(image attached), I have several genres for one show. I want to count the number of each genre in the data set and display it in Tableau
If you have access to database, then take the dump of data in a excel.
Split the data by , and then create a individual column for every word in the genre column.
Now take the excel as source to tableau, In tableau pivot the splitted columns of Genre.
Go to sheet in tableau, Place the pivot field values in rows and count of pivot field values as measures.
You should be able to see the desired result.
This can be done by an alternative method if you know the distinct list of all genre.
what you need to do is to create a separate calculative field for each Genre using
if contains(Genre,'action') then 1 else 0 end
and then use the Sum of these field as the count of Series per genre.
I know this is a hideous task but, it can be done if you do not have any other option.

Tableau table filter for one column only in table

I have a really basic question that I can't figure out. I need to create a table that has multiple calculated fields, but I need only one of the calculated fields to be filtered for a specific dimension value. For example, I have the following data set (dummy data) and I want to create a table that will include total clicks for both companies, but [cost per click] from one company only, company B.
DATA SET
Company| Clicks| $ Cost
------------------------
Comp A | 100 | $20
Comp B | 200 | $40
WHAT I'M LOOKING FOR
CLICKS | COST/CLICK
TOTAL 300 | $0.13
$0.13 comes from 40/300; $40 from company B and 300 clicks from both company A and B.
How do you create a table that has multiple calculations but with one of those calculations filtered on one dimension value only?
One simple calculated field:
sum(if [Company] = 'B' then [Cost] end )/sum([Click])
This should get you in the right direction.
Based on your question and your comment, you want to divide the cost by the TOTAL number of clicks in your dataset.
Create a calculated field called "TotalClicks" and enter this formula
window_sum(sum([Clicks])) // This formula will sum the clicks field for all rows
Create a calculated field called Cost / Clicks and enter this formula
sum([Cost]) / [TotalClicks]
Add the Cost / Clicks field to the sheet and it should look like this
NOTE: If you need to partition / group your report, you may have to play around with this some. I don't use window functions within tableau very often since I usually handle the aggregation at the datasource level instead.
NOTE: Since you mentioned filtering, I will add this statement -- If you filter out any of your data, that data will not (cannot) be included in any calculated fields (To the best of my knowledge and experience, anyway). If you need to include that data (total clicks), I think the only option is to add that aggregated total to your dataset - otherwise, tableau can't calculate it if you are filtering it out.
Edit2: If you cannot change the underlying dataset, you could accomplish this by creating another datasource and joining it to your inital data source --
Data > Add Datasource, add the datasource again and change the name so you can identify it
Click Data > Edit Relationships. Click Custom and REMOVE any linked fields -- this will essentially produce a Cartesian join (every record in your first DataSource will have every reocrd from your second Datasource)
Select the second datasource and create a calculated field (ClicksTotal_DS2) using the same window_sum function
Select the first datasource and create a calculated field (named Cost / Clicks_DS2) using this formula
sum([Cost])/ [Sheet1 (test) (2)].[ClicksTotal_DS2]
Now you can apply a filter to your first data source, and your second data source will still calculate the total.

Count the number of instances of values across multiple dimensions in Tableau

I'm currently looking to count the number of instances a values shared across multiple dimensions. For example, say I have the following set of data:
And I want to return something like:
But ideally in the form of a bar graph. I want to keep the names associated with the data, so I can filter lets say by all "Bobs" or all "Hannahs".
Does anyone have any advice on how to do this in Tableau?
Here are a couple of ways you may be able to do this.
1) Create a calculated field for each food type. This is a bit cumbersome and you would need to add new ones for any new foods added. You calculations would look like this:
Hamburgers:
SUM(IF [Food1] = 'Hamburgers' OR [Food2] = 'Hamburgers' THEN 1 END)
Then you would make use of the Measure Names and Measure Values built-in fields.
2) You can normalize your data. If you are referencing a Excel or Text file, you can do this right in Tableau. Simply go to the Data Source tab, select the Food fields, and choose to Pivot them:
Goes to:
Now you can do:
Finally, both results support creating a bar chart:

Tableau table hides categories with no data - how to prevent?

I have Tableau report where I am showing data by category in columns.
The table shows all columns when there is no filter on data. But when filter is applied, some of the categories do not have data, so table shrinks, hiding columns without data
Is there a way to always show columns regardless of data or not in that column?
Please see screenshots below.
Go to Analysis >Table layout> Show columns with no data or
Analysis>Table layout>Show rows with no data
The next step depends on whether your "disappearing" fields are dimensions or measures.
If you want to force the display of members for specific dimensions, then one (kind of complex) solution is to use an advanced Tableau feature called data blending to force the existence of dimension members, even if there are no related measure values. The trick is to make a simple data source, say a text file, that lists the members of each dimension. Use that source as the primary data source, and make the original data source the secondary source.
Go to Analysis >Table layout> Show columns with no data or Analysis>Table layout>Show rows with no data
Also You can right click on header and select show missing values if you are using line chart.
Solution 1: (When you’re working with Dates or Numeric bins)
Right click on the numerical or Date column to extrapolate the missing values. As you notice in the lower part of the screenshot, this will not work on Categorical data !
Solution 2: Categorical Data
As indicated in the accepted answer, Analysis > Table Layout > Show Empty Rows will get you the same result for Categorical (Text) Data
Solution 3: Calculated Columns
If for some reason, none of the 2 above point & click solutions work, you can create calculated columns to calculate the measure for each of the Categories with the below formula and then line them up on the Columns to achieve the same result
Profit (Category 1)
IF MyColumn = "Category 1" THEN
Profit
ELSE
NULL
END
Profit (Category 2)
IF MyColumn = "Category 2" THEN
Profit
ELSE
NULL
END
Not the most convenient solution when you have hundreds of unique values in your column, but nevertheless a workaround !