I have a table like this and I need average of each subjects of all students(here 2 only)
Student Subject Marks
John Maths 80
John Science 70
John Social 90
Raju Maths 90
Raju Science 80
Raju Social 70
o/p should like this
Subject Average
Maths 85
Science 75
Social 80
You may use below query:
select studentInfo.Subject, avg(studentInfo.marks) from studentInfo group by studentInfo.Subject
Please refer below link:
enter link description here
Related
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.
I have input data like below
CovNo type Price
10 med tot 110
10 med tot 120
10 dent tot 140
20 med tot 110
20 dent tot 130
20 med tot 120
How can i generate the output data like below
CovNo type Price
10 med tot 110
10 med tot 120
10 dent tot 140
10 Group tot 370
20 med tot 110
20 dent tot 130
20 med tot 120
20 Group tot 360
Shall i know the logic to implement the above scenario in Datastage.
Thanks in advance,
Shanmugam
Depending on the source of your data one way could be to solve it with SQL if your source is a table.
If you want or need to do it in DataStage only you could fork your data using a copy stage and have one output fed into an aggregtor stage where you calculate the sums per group. The other output is of the copy is then combined with the results of the aggregator with a funnel stage (which behaves like a union in SQL). That's it.
For the above example, we could achieve it in transformer using the SaveInputRecord() and GetSavedInputRecord() and LastRowInGroup() functions.
IBM has provided a perfect example for this type of scenario.
Note: The performance would be impacted if the data is huge as it uses cache memory. So if your data is huge, then better to split the source and perform a join after the aggregation or you could easily do it using sql if you source is a database.
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 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.
From the Yahoo! PlaceFinder documentation, here are the values for the address quality (the accuracy of the data):
Value Description
99 Coordinate
90 POI
87 Address match with street match
86 Address mismatch with street match
85 Address match with street mismatch
84 Address mismatch with street mismatch
82 Intersection with street match
80 Intersection with street mismatch
My question is with the value 85. How can the address match while the street doesn't?
This will happen when you miss spell the streetname for example, in my case I 'forgot' a vowel in the streetname.
Placefinder gave me the correct coordinates back (the same when I entered the correct streetname) and added a quality of 85