How to include Percentage in ToolTip in Tableau Public - tableau-api

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

Related

Merging tables based on two fields instead of just one?

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???

calculation to determine average per event by year

I have a very large table of data containing cricket information. At the moment I am trying to gather the average number of runs per match for Australia (and other countries) in years 2013, 2014, and 2015. I was able to get the average runs per year into a graph and currently I have a bar chart that looks like this:
year 2013 | 2014 | 2015
total runs 1037 | 1835 | 177
but I would like one that divides that total by the number of matches per year (6, 13, and 1 respectively) and looks like this:
year 2013 | 2014 | 2015
avg runs per match 173 | 141 | 177
but I don't know how to conduct a calculation on these numbers to divide that total over the number of games played. There is a column in my set called 'MID' for Match ID. Obviously, summing the number of MID for 2013 would give me the needed number, 6.
Ideally, I would divide the total number of runs by the number of unique items in the MID column, but I do not know how to do this. If this makes any sense at all, would anyone have a simple way of doing this? I would really appreciate it, as I'm essentially experimenting with this on my own and falling way behind on my other projects.
Assuming you have a column named "Runs" and a column named "MID", then a calculation for Runs per Match would be as follows:
SUM(Runs) / COUNTD(MID)
This gives total runs divided by distinct count of Match ID.

Calculating percentage of survivors per cohort over time in Tableau

In my dataset, I have three columns of data:
CustomerID, BoxCount, MonthCreated
1001 1 Aug 2015
1001 2 Aug 2015
1001 3 Aug 2015
1002 1 Sep 2015
1002 2 Sep 2015
In the screenshot below, I have built a table that displays the count of unique CustomerIDs at each BoxCount level, by cohort (MonthCreated, which is when the customer signed up).
BoxCount level 1 is the full number of people who signed up in MonthCreated X, because everyone who has signed up receives at least 1 box. Then people start cancelling. The number of people who reached BoxCount level 2 for May 2015 (according to the screenshot), is 156,823, or 86.87% of total people who signed up in May (180,525).
I need to create a second column next to the count of customers that displays the % of customers remaining at each BoxCount level, per cohort (people who signed up in the same month).
I have tried using the Quick Table calculation Percentage of Total, with the computation method being "Table (Down)" but it only seems to work for the first month of MonthCreated. I would like for each subsequent month to have 100% for BoxCount level 1, and the following % to be a portion of the number at each month's level 1. I can't figure out why for July, the % starts at 83.89% and not 100%.
Can anyone help me figure out how to calculate this percentage and also to add it as a new column instead of replacing the column of raw counts?
Thanks!
Looks like you're almost there. Did you try changing the calculation definition by changing the values it summarizes from or the level?
Some example:
And for it to be replacing the column of raw counts, you can just add the raw counts column again in your view and you'll have both.

Crystal Reports Pie Chart - How to show 0 values in legend

I am creating pie charts in Crystal Reports to show the number of grades awarded to a student in various tests throughout the year. A student can be awarded a grade 5, 4, 3, 2 or 1 only. Here is an example of a pie chart for one student.
This student did 5 assessment points in the class shown in 2014. He got a grade 5 for one assessment, Grade 4 for 3 assessments and then one Grade 3 for another assessment.
Is there any way, in the legend, of showing the colours that are used for Grades 2 or 1 and showing them as 0%. that is, how can I show all 5 grades in the legend, and, if a student hasn't received that grade, it still shows in the legend with a count of 0 and 0% next to it?
Any help greatly appreciated.

Data duplication in Detail band

I have a Group band with Detail band between the Group header and Group footer. The report is supposed to print multiple student examination records at once. I have grouped them according to the registration numbers. It works except for the fact that query results are shown twice.
as shown
Student 1
Subject score
Maths 50
English 60
kiswahili 70
Maths 50
English 60
kiswahili 70
Student 2
Subject score
Maths 90
English 60
kiswahili 60
Maths 60
English 60
kiswahili 60
insted of
Subject score
Maths 50
English 60
kiswahili 70
Student 2
Subject score
Maths 90
English 60
kiswahili 60
Add an ORDER BY to the end of your query:
ORDER BY registration_number, subject
Your data should be sent to the report template in the order in which it will be displayed. Order by student and then by subject.