Number each nested table inside a master table on a Jasper report - jasper-reports

So i have the following issue. In my database I have a table named
bp_minutes_app.
This table stores records of minutes from committee meetings. Each minute can consist of many files. The database design regarding minutes is the following:
The table bp_minutes_attachments is connected via a foreign key to the bp_minutes_app and holds the following information:
description, createdby
The table
bp_files
is connected via a foreign key to the
bp_minutes_app
and holds the file along other information. We are interested in taking only the name and id of the file (the latter in order to create a hyperlink to the file, but this is out of scope of the present question).
Final remark. All those tables are linked to the master
bp_full
table that is joined only to get the id of each specific report.
In my report I want to print on a table all minutes and the accompanying information (file name, description, createdby, submission date), but make a separate entry for each minute. In order to achieve this, I first created a table that uses the following dataset:
SELECT bp_minutes_app.id
FROM bp_minutes_app
INNER JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
WHERE bp_full.id = $P{id}
With this dataset I retrieve each minutes record. In my example, I get two records with ids 39 and 40.
Inside this table I nested another table to retrieve information for each file in each minutes record. The dataset that I used is the following:
SELECT bp_minutes_app.submission_date,
bp_minutes_attachments.createdby,
bp_minutes_attachments.description,
bp_files.id,
bp_files.name
FROM bp_minutes_attachments
left JOIN bp_minutes_app ON
bp_minutes_attachments.bp_minutes_app_id = bp_minutes_app.id
AND bp_minutes_app.id = $P{mid}
left JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
left JOIN bp_files ON
bp_minutes_attachments.bp_file_id = bp_files.id
WHERE
bp_full.id = $P{id}
The id parameter is used again to take the specific report and the mid parameter to take a specific minute. On parameter specification mid is declared as follows:
mid = $F{id}
, where id is the bp_minutes_app.id.
Following this setup I managed to get nested tables for each minute (forgive me for the greek headers):
What I want to do is number each subtable from 1...n, according to the number of minutes/ subtables. How can I achieve this? I tried to create a suitable variable but it was not met with success. I want to somehow "save" in a parameter / variable the count of bp_minutes_app records and manipulate this number for each nested table header, instead of just numbering each table with the corresponding id.
Sorry for the long post but I am new to Jasper and I wanted to be clear about the steps I have taken and what I want to achieve.

Alot of sql not much jrxml in your post so I start by guessing.
Have you tried something like this in the jrxml:
<variable name="counter" class="java.lang.Integer" calculation="Count">
<variableExpression><![CDATA[$F{id}]]></variableExpression>
</variable>

Related

Microstrategy Lookup Table join

Lookup table (State)
In this table I have 4 Columns (Region_id,RegionName,State_id,State_name)
2.Fact table
In this I have couple of Columns like(customer,product,date,Region_id,State_id,Revenue, Profit)
In lookup table there are more number of states whereas in fact we have data only for few states.
My requirement is to display all the sates in report even though there is no corresponding data available in fact.i have set the state table as lookup for state attribute.
If I pull the state attribute and a metric from fact and set vldb properties preserve lookup table then I'm getting all the sates and it's metric values and null for the one which don't have metric value.
Now If I add some attribute like customer or product along with it I'm not getting all the sates..I'm getting only the states which have data in fact since on adding some attribute the mstr is not hitting state table at all it's bringing data from fact itself.
What could be done so tat I can get all the sates and null even for the customer and product..?
You could try forcing your metrics to outer-join on the dataset itself while preserving final pass elements to make a left join.
Within developer, navigate to your dataset/cube and open it up in editable mode.
Select "Data" within the top bar of the cube/dataset editor >> Report Data Options >> Metric Join Type.
Here you will see your Metrics. Change the join type from inner to outer. Rerun the report and it should bring back all the data you need.
Let me know how it goes.

Tableau - Passing result of one calculation as a filter to get data from another data source

I have 2 datasources. One Data Source provides details of employee (ID, Name etc) and their Departments. This is a Database. Another datasource is a manually maintained excel sheet in a sharedrive that has employee ID and a flag that states if the employee is a New Joiner Or Leaver. This dashboard however doesn't have Department information of employees.
I need a create an Dashboard, where the user can select a department and get details of employees that are flagged as Leavers in the excel datasource.
How can this be achieved?
I suggest you join your data in Tableau. First put your database table and then join excel to it. Use ID as a join key.
By joining you will have a dataset where flag is one column among others.

data merging in Tableau

I have two sheets in excel. One has CBG (neighborhood) IDs as shown below.
The second sheet has state and county names and IDs as shown below.
Now the first 5 digits in the CBG ID are just the corresponding state and county IDs for that CBG.
I need to to join this data together in Tableau so that I would have the state and county on the CBG sheet for each CBG.
Basically I tried to blend the data and it didn't work. I also tried to perform a join calculation using the 5-digit code in the second sheet and the LEFT function to extract the 5-digits in the CBG code but it didn't seem to work either.
To fix it, just needed to fix the Join calculation on both sides of the join.
Also, it seems that both variables to be joined need to be the same data type.
The data that you analyze in Tableau is often made up of a collection of tables that are related by specific fields (that is, columns). Joining is a method for combining the related data on those common fields. The result of combining data using a join is a virtual table that is typically extended horizontally by adding columns of data.
When joining tables, the fields that you join on must have the same data type. If you change the data type after you join the tables, the join will break.
Please go through the below steps for joining tables:
In Tableau Desktop: on the start page, under Connect, click a connector to connect to your data. This step creates the first connection in the Tableau data source.
In web authoring: Select New Workbook and connect to your data. This step creates the first connection in the Tableau data source.
Select the file, database, or schema, and then double-click or drag a table to the canvas.
Double-click or drag another table to the canvas, and then click the join relationship to add join clauses and select your join type.
Add one or more join clauses by selecting a field from one of the available tables used in the data source, a join operator, and a field from the added table. Inspect the join clause to make sure it reflects how you want to connect the tables.
When you are finished, close the Join dialog.
Thank you.

ms access form listbox changing whole field

I have created a form to update a query that that is in turn based on a master table containing information on a number of files. This master table is then related to several other tables in say for example a table called group_table, defining which group the file would belong to, which contains an ID field and the group_name. This is then related in a one-to-many relationship with the master table based on the group.ID and a field in the master table master_table.group and joined in the query the form is based on.
In the form I have designated a listbox control to update the group field of the query/master table. The contents available for selection in the list box were set based on the group_name field from the group_table table which is defined in the RowSouce section of the property sheet of the form.
So my issue is that when I try and update any records in the query using the listbox in the form, all of the records that are the same will get changed as well. E.g., changing a record in one row from "Group A" to "Group B" will change all the records containing "Group A" to "Group B" in the group field. So I was wondering if there is anything I can do to set it so only the specific record that I want to change gets changed.
When you are making the call to update the table you should make sure that you are using WHERE along with the primary key to make sure that you update that row only. An example would be a statement similar to the one below.
CurrentDb.Execute "UPDATE [group_table] AS G INNER JOIN [master_table] AS M
ON G.[ID] = M.[groupID]
SET G.[group] = '"& Group A & "'
WHERE M.[groupID] = '" & groupIDFromForm & "';"
Apply the ON from the join so that the foreign key and primary key are going to share the same value, and from there use the form to create a variable that you can use to identify the exact row. From there the program should execute the query correctly.

Reporting Services and Dynamic Fields

I'm new to reporting services so this question might be insane. I am looking for a way to create an empty 'template' report (that is basically a form letter) rather than having to create one for every client in our system. Part of this form letter is a section that has any number of 25 specific fields. The section is arranged as such:
Name: Jesse James
Date of Birth: 1/1/1800
Address: 123 Blah Blah Street
Anywhere, USA 12345
Another Field: Data
Another Field2: More Data
Those (and any of the other fields the client specifies) could be arranged in any order and the label on the left could be whatever the client decides (example: 'DOB' instead of 'Date of Birth'). IDEALLY, I'd like to be able to have a web interface where you can click on the fields you want, specify the order in which they'll appear, and specify what the custom label is. I figured out a way to specify the labels and order them (and load them 'dynamically' in the report) but I wanted to take it one step further if I could and allow dynamic field (right side) selection and ordering. The catch is, I want to do this without using dynamic SQL. I went down the path of having a configuration table that contained an ordinal, custom label text, and the actual column name and attempting to join that table with the table that actually contains the data via information_schema.columns. Maybe querying ALL of the potential fields and having an INNER JOIN do my filtering (if there's a match from the 'configuration' table, etc). That doesn't work like I thought it would :) I guess I was thinking I could simulate the functionality of a dataset (it having the value and field name baked in to the object). I realize that this isn't the optimal tool to be attempting such a feat, it's just what I'm forced to work with.
The configuration table would hold the configuration for many customers/reports and I would be filtering by a customer ID. The config table would look somthing like this:
CustID LabelText ColumnName Ordinal
1 First Name FName 1
1 Last Name LName 2
1 Date of Birth DOBirth 3
2 Client ID ClientID 1
2 Last Name LName 2
2 Address 1 Address1 3
2 Address 2 Address2 4
All that to say:
Is there a way to pull off the above mentioned query?
Am I being too picky about not using dynamic SQL as the section in question will only be pulling back one row? However, there are hundreds of clients running this report (letter) two or three times a day.
Also, keep in mind I am not trying to dynamically create text boxes on the report. I will either just concatenate the fields into a single string and dump that into a text box or I'll have multiple reports each with a set number of text boxes expecting a generic field name ("field1",etc). The more I type, the crazier this sounds...
If there isn't a way to do this I'll likely finagle something in custom code; but my OCD side wants to believe there is SQL beyond my current powers that can do this in a slicker way.
Not sure why you need this all returned in one row: it seems like SSRS would want this normalized further: return a row for every row in the configuration table for the current report. If you really need to concatenate then do that in Embedded code in the report, or consider just putting a table in the form letter. The query below makes some assumptions about your configuration table. Does it only hold the cofiguration for the current report, or does it hold the config for many customers/reports at once? Also you didn't give much info about how you'll filter to the appropriate record, so I just used a customer ID.
SELECT
config.ordinal,
config.LabelText,
CASE config.ColumnName
WHEN 'FName' THEN DataRecord.FirstName
WHEN 'LName' THEN DataRecord.LastName
WHEN 'ClientID' THEN DataRecord.ClientID
WHEN 'DOBirth' THEN DataRecord.DOB
WHEN 'Address' THEN DataRecord.Address
WHEN 'Field' THEN DataRecord.Field
WHEN 'Field2' THEN DataRecord.Field2
ELSE
NULL
END AS response
FROM
ConfigurationTable AS config
LEFT OUTER JOIN
DataTable AS DataRecord
ON config.CustID = DataRecord.CustomerID
WHERE DataRecord.CustomerID = #CustID
ORDER BY
config.Ordinal
There are other ways to do this, in SSRS or in SQL, depends on more details of your requirements.