JasperReports Crosstab Query - jasper-reports

I'm using JasperReports \ iReport crosstabs to create a matrix of student and results.
So for example Jim is doing subjects A, B, C and Sally is doing A, C
What I want is something like:
Subj-A Subj-B Subj-C
Jim P M D
Sally D D
But as my SQL orders by name then subject I get:
Subj-A Subj-B Subj-C Subj-A Subj-C
Jim P M D
Sally D D
As you can see in the above the results are correct but the formatting is woeful.
Is there anyway I can generate the reports to use names and subject only once
and filling in the values from here?

To follow-up on this.
JasperReports is primarily used to represent the data so the work here needs to be done here via the SQL.
In a case where there is a crosstab of X vs Y we may need to use a cross-join which bacically compute all the combination of X subject and Y students.
After the cross-join we can use an outer-join on the candidate details to find there results. After this it is a basic matter of representation in Jasper.

Related

How to avoid CIRCULAR REFERENCE in TABLEAU using LOOKUP and PREVIOUS_VALUE?

Hello!
In Excel I have 2 columns C and D with formulas in there for a specific purpose.
As an Example I have here cells C12 and D12 in these 2 columns to show he formulas.
C12 = 0.001855 * B12/E12 + 0.998145 * (C11+D11)
D12 = 0.981119 * (C12-C11) + 0.018881 * D11
Let's say the C-column variable is "Running Base" and the D-column variable is the "Growth" and the rows are months. And say I want to copy these formula's to a Tableau worksheet with months in the rows.
You see that C12 is using both it's own previous value C11 (the lag -1 of C) and the lag -1 of D (D11). I can find C11 in the formula in TABLEAU using the PREVIOUS_VALUE function and the previous value of D with the LOOKUP([D],-1) function (the B12 and E12 are not important for the discussion).
Then D12 is also using it's own previous value D11 and both C12 and its previous value C11. Of course we can do similar TABLEAU exercises here, but you already feel a CIRCULAR REFERENCE error coming up ;-).
So, there is no actual CIRCULAR REFERENCE and it's working in Excel. But I do understand why TABLEAU is giving one and I am sure there must be a work-round to this.
Can anybody help please???
Thx very much in advance!!
Herman Mentink
One way to solve this is to drop the calculation in Details part of the Marks and then reference the rows of that field in calculation which doesn't create a circular reference else you are correct tableau will create a circular reference error as behaviour is different from Excel.
Edit----------------------------------------------------------------
Not just a tool tip infact you can use those in calculated fields aswell, Few months back I have implemented same in my report.
A calculation creates 4 rows in my report and I need to do (1st row+4th row) in the same column, so I dropped the calculation in Detail on the Marks and referred same another calculated field. Just check the below example code:
LOOKUP(ATTR([Values]),FIRST()+4) + LOOKUP(ATTR([Values]),FIRST()+1)
Values is the calculated field now above caluction is referring to Values and picking rows 2 and 5 which I can't use directly on the Values column if I drop Values on Text in Marks
In the above image values in detail is original calcualtion and the one I used in text is the referring to values and displaying.

Identify missing Dimension Value in Tableau

I have student name, subject and marks in three columns. My use case is to identify the subject in which selected student has not enrolled. I can do it very easily using SQL but requirement is to identify it in Tableau. I have tried LOD's and Traditional Filters but it's of no help.
**Sample Data**-
Name Subject Marks
Rob A 90
Rob B 95
Rob C 98
Ted B 86
Ted D 70
**Desired Output**-
Name Subject
Rob D
Ted A
Ted C
If graphical solutions are also an option, you can print the Subjects on e.g. the X axis, and the Student Names on the Y axis. Then, set the marks type to e.g. text and display the Number of Records in each cell. This way, you should get a matrix of all Subject vs. all Students, with 0 or 1 in each cell (intersection).

Tableau - Name Rank, by State / Year / Gender

I have a data set downloaded from the Social Security website. The data is in the form below, and contains the popularity (i.e., as defined by Count) of names, by gender, year and state:
State Gender Year Name Count First Letter
AK F 1910 Anna 10 A
AK F 1910 Annie 12 A
AK F 1911 Annie 6 A
AK F 1912 Alice 5 A
AK M 1912 Wilbur 7 W
AK M 1912 Thomas 7 T
Within Tableau, I'd like to Top X names by each of these categories (or all if not filters are applied). However, when I use a Top filter in a visualization, the underlying data produced by the filter is the form:
For example, I need the first ranked name, and be able to use filters to see how that changes by year, gender, and state. I'm thinking this might be accomplished by an LOD expression, but not sure where to start.
You can achieve this without needing a LOD calculation. Simply change your filters from standard blue dimension filters to be context filters. To do this simply right click on the filter when it is in the filter pane and click "Add to Context". The filter will be shown as grey. Now all ranks will be calculated after filters have been apllied
Why does this work? It is to do with the Order of Operations in Tableau. A calculation such as rank is a table calculation. As the name implies the calculation is processed on the entire data table before dimension filters are applied. However, when something is a context filter it creates temporary tables which are then used to calculate table cals.
Find out more here: https://www.google.com.au/search?q=order+of+operations+tableau&oq=order+of+operations+tableau&aqs=chrome..69i57j0j69i65j0j69i65j0.3475j0j7&sourceid=chrome&ie=UTF-8

Aggregating from multiple columns in Tableau

I have a table that looks like:
id aff1 aff2 aff3 value
1 a x b 5
2 b c x 4
3 a b g 1
I would like to aggregate the aff columns to calculate the sum of "value" for each aff. For example, the above gives:
aff sum
a 6
b 10
c 4
g 1
x 9
Ideally, I'd like to do this directly in tableau without remaking the table by unfolding it along all the aff columns.
You can use Tableau’s inbuilt pivot method as below, without reshaping in source .
CTRL Select all 3 dimensions you want to merge , and click on pivot .
You will get your new reshaped data as below, delete other columns :
Finally build your view.
I hope this answers . Rest other options for the above results include JOIN at DB level, or creating multiple calculated fields for each attribute value which are not scalable.

Using variable length data inputs with EM algorithm clustering

We have a set of sequences with taxi positions. We want to cluster the data by considering the sequential patterns in the data lines.
For example:
T1, T2, T3, T4 be the travels and a,b,c,d,e be set of places.
The data we have is like,
T1 b c b a d
T2 a
T3 a b a b a b c e d
T4 b c d c b d c a
But the problem is the length of the data are not variable. How can we cluster these type of data using EM. Since it does not accept variable length data is there way we can customize it.
EM is a general principle. You can use it with very different models.
Probably the most popular model for EM is Gaussian Mixture Modeling, GMM.
Naturally, if you use covariances, GMM requires a fixed dimensionality.
But if you use other models, there is no reason it cannot work with variable length vectors. For example, there are EM variants that process text data, and text usually does have different length.