How do I create a single bar chart from three independent data sources? - bar-chart

Input
I have three datasets (simplified example below):
List of students from school A and their age (1200 records)
List of students from school B and their age (200 records)
List of students from school C and their age (2000 records)
Every dataset has two columns: studentId and age.
Desired result
I want to create a bar chart that shows the distribution of age across these schools. For easy comparison I would like to have:
one bar chart
with three legend entries:
A
B
C
7 categories:
age =< 12
age = 13
...
age >= 18
What I have tried
I tried linking the datasets, but due to the different number of students and the various studentId formats per school this did not work.
I tried using the studentId columns of the three datasets as the value and the age column of every dataset as the axis. This only worked one dataset at a time. I needed to "Go to the next level in the hierarchy" to see the other dataset.
How else can I achieve this?

You can go into Power Query Editor:
And you will need to add a new column for each datasheet with the legend you want, for example:
So your tables should look like this:
Then merge the tables with Append Queries as New:
Select Three or more tables, and add the three tables:
And there you have your three tables merged into one.

Related

MySQL Query to get student grades AND class average

I am fairly new to the world of SQL and am finding the syntax a tad bit awkward to work with while I try to understand how joins and such work. I am practicing by building a small web app that lets you pick a date and possibly a name of a student (if none is defined then all students are shown). My idea is that basically multiple tables (one per student) will be generated off of a given query and it would show the student's name and other related info, along with this it also will show the average grade of all the students along side that specific students information. However, I am not sure how to actually make a query that will return all the students, those with and without grades on a given date, alongside the overall average of that test/quiz on said date.
The tables I am working with are student which has a student_id, name and sex. An Event table that has an event_id, type (test or quiz) and a date. And finally a score table that has an event_id, student_id and a score.
Essentially the resulting query would return a table with these columns.
| student_id | Name | Date | Type | Grade | Class Avg |
every row is a unique student, the date the given test or quiz was taken on, the grade they got (if they took test/quiz, otherwise it's NULL) and then the class avg for that test/quiz. I know how to get everything up to the class average. I'm not even sure if it is or isn't possible without doing 2 queries or to calculate it myself while rendering the webpage.

How can I split my measure into different columns by month in Business Objects WebI?

This task is to be completed using SAP Business Objects WebI 4.2.
I have a table in the following format:
Company Date Amount
A 1/1/2014 100
A 16/2/2014 400
I have a variable called Month that has the Month for each transaction.
I want the table to look like:
Company January February
A 100 400
How can this be done without making a calculated field for each month?
In Webi you can't easily place a distinct category (Company) next to the values of another category (Month) in the same header row. So you have two options:
1) Create a regular horizontal table with three columns: Company, Month, & Value
2) Create a crosstab table with the Company on the left/vertical axis and the Month on the top/horizontal axis. Your values would be in the middle.
Note: if you wanted to do a lot of manual coding, you could set it up the way you want. The first column would hold your Company variable. The next column, "January" would require a formula:
=if([Month]=January) Then [Value]
You'd then have to create 11 more columns, with variables for each:
=if([Month]=February) Then [Value]
=if([Month]=March) Then [Value]
=if([Month]=April) Then [Value]
etc...
It would be tedious to do, and personally I'd go for one of the first two options. But it would work!

SSRS Show a percentage of a a total value

I have a regular Table in SSRS. With 3 Groups...
(Parent) STORE - CLERK - PRODUCT (Child)
I have some regular aggregations. How many PRODUCTS Sold by a CLERK , How Many CLERKS Per STORE and Eventually How many PRODUCTS Per STORE
On top of the Regular Sums And Avgs, I need To Find Out The Percentage of PRODUCT (Type) Meaning a Particular value of that Group.
Example STORE 001 Has Sold 10 RADIOS (a PRODUCT) and There has Been 100 RADIOS sold by all Stores
So Basically What I Need is to show STORE 001 is Responsible for 10% of all RADIO Sales.
(A note: Ideally , I would Like to show this To adjust to the Data - So if I add new products It will group those as products (Naturally) but still give me those percentages)
= fields!product.value / sum(fields!product.value)
in its most basic form you would want to use something like this.
The first will give you the total of the current row of data and the second will give you the total of all rows of that product.
Thus you would have 10 / 100 (per your example).
This is assuming that you have your data structured correctly. Depending on the structure of you report you may need to add a scope to your total summation to make sure that you are not totaling any other datasets that may reference the same product or field.
sum(fields!product.value, "--your dataset here--")

DB table creation -- breaking down age groups

I have a tutoring website where teachers list their preferences for the ages of their potential students.
So far, I have broken those ages into the following categories:
0-4, 5-9, 10-14, 15-19, Adults. These categories, I think, represent decent break points for students ages. But no matter -- the real issue is table creation.
I will make a secondary table, teachers_ages, with a foreign key for teacher_id and another column for age. Should I make this column an enum, with the following acceptable choices '0-4' '5-9', '10-14', '15-19', 'Adults'?. Is this somehow bad-practice (to group numbers with words?) Does it violate any database creation norms? Is there a better way to break age groups for use with CRUD?
Update: teachers can choose as many age groups as they want
Typically you would create a lookup table which would list an identifier and the associated value. For example
Lookup table (AgeRange)
ID Min_Age Max_Age Description
1 0 4 "Less than 4"
2 5 9 "5 to 9"
3 10 14 "10 to 14"
4 15 19 "15 to 19"
5 20 1000 "Adults"
Now you can add another table with the teacher id and the age range id. (There can be more than one entry in this table allowing teachers to have any number of preferences.)
When validating you join to this table and look at Min_Age and Max_Age. When reporting you use the Description field.
If each teacher can only choose one age group you do not need to add a second table. Put the age-group field in the teacher table. Set the datatype as varchar and use check constraints for your five choices.
Your approach is a valid way to break groups down into demographics, such as age, income, population, etc.

Microsoft Access 2010 - Filtering by a caculated field in a query-based report

Ok, here's the condensed form. I have three main tables to draw data from:
StudentData - PK is the student's ID Number. Contains contact info, their current status ('00' for none, 'P' for Probation, 'S' for Suspension), and cumulative gpa data.
CourseData - PK is the CRN. Contains just the abbreviated subject and the course number (IE ECON 200)
StudentCourses - PK is an AutoNum. Many-to-Many relationship table between StudentData and CourseData. Also contains stats for the particular student's class (grade, credit hours, etc).
So some sample data would look like:
-
StudentData
ID: 12345678
Name: John Doe; ...[Other contact info]; 00; CumCreditHours: 100; CumCoursePoints: 190
-
CourseData
CRN: 0001; Abbrev: ECON; CourseNumber: 101
CRN: 0002; Abbrev: CSCI; CourseNumber 201
-
StudentCourses
AutoNum: 1
StudentID: 12345678; CRN: 0001; Grade: A-; Credits: 3
AutoNum: 2
StudentID 12345678; CRN: 0002; Grade: B; Credits: 3
-
At this point, this is how I have things set up:
First, a query runs that finds all of the courses a student takes and converts the letter grades into a point value. Another query based on the first sums the point totals and the credit hours. A third query takes those totals and calculates the GPA by dividing their point total by the credit hour total.
Separately, a query runs that calculates the student's cumulative GPA by taking their cumulative points and hours from the StudentData table (again dividing the points by the hours).
Then, another query takes both the semester GPA, cumulative GPA, current status, and cumulative credit hours and calculates the recommended action for the student. So for our example data it would look like:
_
SemesterGPA: 3.33; CumulativeGPA: 1.90; CurrentStatus: 00; CumulativeCreditHours: 100
_
I have the formula to determine their recommended action set up as a series of nested IIF statements that looks like:
IIf([CurrentStatus]="00" And [CumulativeGPA]<2 And [CumulativeCreditHours]>=12 And [CumulativeCreditHours]<=23,"PFY",IIf([CurrentStatus]="00" And [CumulativeGPA]>=1.7 And [CumulativeGPA]<=1.99 And [CumulativeCreditHours]>=24,"P",IIf([CurrentStatus]="00 " And [CumulativeGPA]<2 And [SemesterGPA]<2 And [CumulativeCreditHours]<12,"W",IIf([CurrentStatus]="00" And [CumulativeGPA]>=2 And [CumulativeGPA]<=2.5 And [SemesterGPA]<2 And [CumulativeCreditHours]>=12,"WUP",IIf([CurrentStatus]="00" And [CumulativeGPA]<1.7 And [CumulativeCreditHours]>=24,"SUSP",IIf([CurrentStatus]="P" And [CumulativeGPA]<2 And [SemesterGPA]>=2 And [CumulativeCreditHours]>=12,"CP",IIf([CurrentStatus]="P" And [CumulativeGPA]>=2 And [SemesterGPA]<2 And [CumulativeCreditHours]>=12,"SPCP",IIf([CurrentStatus]="P" And [CumulativeGPA]>=2 And [CumulativeCreditHours]>=12,"RP",IIf([CurrentStatus]="P" And [CumulativeGPA]<2 And [SemesterGPA]<2 And [CumulativeCreditHours]>=12,IIf(IsNull([PriorSuspension]),"S(FD)","D(SD)"),"None")))))))))
For our example, John Doe's recommended action would be 'P' since his current status is 00, he has over 24 cumulative credits, and his cumulative gpa is between 1.7 and 1.99.
Now for the problem: I would like to be able to make a report that can filter by the recommended action. I've detailed the issues I've had previously, but in short, the way I have the reports set up now (with the information being displayed in a sub-report inside a report that is based on the StudentData table to provide the aforementioned queries with the StudentID) doesn't allow me to do this because the field I want to filter by exists in the sub-report and not the main report (and you can't set the filter properties for a sub-report).
Any ideas?
Ok, I've got this to work now. I realized that as I was calculating the semester GPAs that I had grouped the results together by ID at some point during the process. This allowed me to remove the part of the initial query that grabbed the ID number from the form. Since the last query in the process linked everything together by student ID, the individual records held all of the information I needed and everything fell into place after that.
I half expected something simple like this to be the answer to my problem, but I'm still disappointed that it took me this long to figure it out...
Anyway, thanks to anyone who might have been thinking of possible solutions for this problem.