I Know how to split the country column into multiple columns(Using custom split I split them on the comma's) but I am not sure how to merge them like shown below(What I want). Any help is greatly appreciated
**What I have**
ID Type Country
1 TV Show USA, UK, Spain, Sweden
2 Movie USA, India
3 Movie USA
4 TV Show Bulgaria, USA
5 Movie Sweden, Norway
6 Movie UK, USA
7 TV Show Germany
8 TV Show India
9 Movie USA, India
10 Movie USA
**What I want**
USA
UK
Spain
Sweden
USA
India
USA
Bulgaria
USA
Sweden
Norway
UK
USA
Germany
India
USA
India
USA
It's actually something you can do in the datasource pane, even though it may not make much sense "inside" Tableau for "data handling".
As you said the first step is splitting your Country column; doing so, for each row you will get N columns where N equals the number of country for the row having the highest number of countries (4 in your example).
Rows having just 1 country will have just the first column with a value and the rest will be null value columns.
Once you have done the first step, you need to pivot your data selecting those N columns, right-click and select pivot.
Doing that you will get N*M rows where N is the maximum number of countries per original row (4) and M is the number of your original rows (10).
Since, as said before there could be null values, the final step should filtering out all "new rows" having null values.
Related
I have data on sites where invasive species have been managed, and I'm trying to merge information between two tables based on two fields.
The first table includes things like site code, species, area.
Site Code
Scientific Name
Area
001
Alliaria petiolata
Area 1
002
Clematis ternifolia
Area 2
003
Clematis ternifolia
Area 3
The second table has the "tier" or rank of importance according to experts (i.e. 1 means most important, 4 means least important, and there are some confusing letter categories as well).
scientific name
Area 1
Area 2
Area 3
Acer palmatum
2
M
M
Alliaria petiolata
4
4
4
Clematis ternifolia
4
1a
3
I'm trying to add a new column to the first table (because the actual thing has way more information) that shows the tier for that site code, based on the species and area.
Site Code
Scientific Name
Area
Tier
001
Alliaria petiolata
Area 1
4
002
Clematis ternifolia
Area 2
1a
003
Clematis ternifolia
Area 3
3
I'm not even really sure how to approach this because it's like a merge but it's contingent upon two pieces of information. I don't really want to do a giant if-else block.
Any ideas???
Issue: When more than one state is selected in Filters the average is not calculated as expected. For a single state, it is working fine.
The data source contains the following Dimension and Measures -
Dimension: SKU, Country, State, Run Date
Measure: Profit
Dataset is as follows -
Country
State
Run Date
SKU
Profit
USA
Texas
2022-06-01
Table
20
USA
Texas
2022-06-01
Chair
30
USA
Ohio
2022-06-01
Table
5
USA
Ohio
2022-06-02
Table
10
Expected Result of Average (Country and State are used as Filters. Profit is used in values)-
SKU
2022-06-01
2022-06-02
Table
12.5
Chair
15
5
Current Result of Average (Country and State are used as Filters. Profit is used in values)-
SKU
2022-06-01
2022-06-02
Table
12.5
Chair
30
10
I have tried Window_AVG and used SUM and COUNT in the Calculated field but the results are not as expected.
Kindly help with a solution to solve the Averaging issue. Thanks a lot for the support.
For the sake of the exercise, let's assume that I'm monitoring the percentage of domestic or foreign auto sales across the US.
Assume my dataset looks like:
StateOfSale | Origin | Sales
'CA' | 'Foreign' | 1200
'CA' | 'Domestic' | 800
'TX' | 'Foreign' | 800
'TX' | 'Domestic' | 800
How would I show the percentage of Foreign Sales, by State of Sale, but each State is a line/mark/bar in the visual?
So for CA, the Foreign Percentage is 60%. For TX, the Foreign Percentage is 50%.
This is what Tableau was born to do!, and there are a lot of great ways to visualize this type of question.
Use a Quick table calculation called "Percent of Total" and compute that percentage according to each State. In the picture below, "StateofOrigin" is in Columns, and "Sum(Sale)" is in Rows, I compute using Table (Down).
You can also graph the raw sales numbers in addition to displaying the text percentage to gain additional context about the number of sales between states.
Finally, if you've got a lot of states, it can be cool to plot it out on a map. You can do this by creating a calculated field for percentage and then filtering out the domestic sales.
Field Name: Percentage
SUM([Sale])/SUM({FIXED [StateofOrigin]: SUM([Sale])})
I created the below view that gives No. of students got PASS/FAIL in each subject . The tool Tip gives me some default options.
But I would like to have Percentage in tool tip
Basically I need Percentage field in tooltip that says 50% for below screen.
PASS Percentage 50%
FAIL Percentage 50%
This Percentage field needs to vary as per each subject and its grade among students
Could somebody help me on steps to include Percentage in Tooltip?
sample dataset
id name age gender subject grade
100 Steve 14 MALE ENGLISH PASS
100 Steve 14 MALE PHYSICS PASS
100 Steve 14 MALE CHEMISTRY PASS
101 Edward 15 MALE ENGLISH FAIL
101 Edward 15 MALE PHYSICS FAIL
101 Edward 15 MALE CHEMISTRY FAIL
102 Andy 15 FEMALE ENGLISH PASS
102 Andy 15 FEMALE PHYSICS PASS
102 Andy 15 FEMALE CHEMISTRY FAIL
103 Kim 16 FEMALE ENGLISH FAIL
103 Kim 16 FEMALE PHYSICS FAIL
103 Kim 16 FEMALE CHEMISTRY PASS
Table calcs let you calculate percent of totals without creating new calculated fields.
Put SUM(Number of Records) on the Tooltip shelf. Then click on it and choose Quick Table Calc->Percent of Total. You will see a triangle icon next to the field indicating it is now a table calculation
Experiment with changing the Compute Using setting for the Field. I believe compute using Grade is probably the one you want.
I did this with a few calcs. First, get the PASS count.
if [Grade] = 'PASS' then 1 END
Then create a Pass % calc.
sum([Pass count]) / total(countd([Id]))
Now you can place this field in the Tooltip. Repeat for FAIL as well and place that in the Tooltip.
Then I updated the tooltip as follows:
Number of students <CNTD(Id)> (<AGG(pass %)> <AGG(fail %)>) who got a <Grade> in <Subject>
see sample workbook here for details. https://dl.dropboxusercontent.com/u/60455118/160326%20stack%20question.twbx
I have Customer ID, Product ID, and Industry columns. For example:
**CustomerID ProductID Industry**
1 A Entertainment
1 B Entertainment
2 A Entertainment
3 A Entertainment
4 A Entertainment
4 B Entertainment
4 A Cleaning
I have a grid set up with industry for my columns and Product ID for my rows.
For example,
Entertainment Cleaning
A
B
I'm trying to find the % of customers in a specific industry purchasing each product.
In other words the (number of unique customers by Product ID)/(Unique customers in each industry).
The numerator is: COUNTD([Customer ID])
The denominator is throwing me off. I'm not sure how to get unique customers in a segment.
In the example above, product A has 4 unique customers in the Entertainment industry, and Entertainment has 4 unique customers for all products, so the calculation for product A would 4/4 or 100%.
But product B would be 2 unique customers / 4 total unique customers in Entertainment or 50%.
Does anyone know how I create the calculation for the denominator.
COUNTD([Customer ID])/???