Get the value of visible column of JasperReports Server input control? - jasper-reports

I have a report in JasperReports Server 5.2.0, in this report I have two input control
first one is:
COUNTRY (value column- COUNTRY_ID, visible column- COUNTRY_NAME)
and another one is
STATES (value column- STATE_ID and visible column - STATE_NAME).
These two parameters I am passing to the report, now at the end of the report I want to show the input parameter selection value so user can see what he has selected. But I am not able to get the visible values of parameters. I can print only value column value.
So my question is there any way to print the visible column values of input control in reports?

Till now , Visible Columns are not passed,where Value Columns are passed to Jrml File in Jasper.
To answer you question There is a way to print the visible column values.
It can be done using Sub-queries, by using 'Value Column' passed to the JRML file.
Then add the subquery to your main query and it`s done!!
In the above scenario You can display
State Name
SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID} - If it is Single Select input control
SELECT GROUP_CONCAT(States.STATE_NAME) from States WHERE state_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control
Country Name
SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id= $P{COUNTRY_NAME} - If it is Single Select input control
SELECT GROUP_CONCAT(Country.COUNTRY_NAME) from COUNTRY WHERE country_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control
Suppose this your main query where Country and State are missing..
SELECT
`id`,
`product-id`,
`name`,
`description`,
`branch`,
`stock`,
`price`
FROM
`products`
WHERE
`name` LIKE "%car%"
The modified query will looks like..
SELECT
`id`,
`product-id`,
`name`,
`description`,
`branch`,
`stock`,
`price`,
(SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID}) as state,
(SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id=P{COUNTRY_NAME}) as country
FROM
`products`
WHERE
`name` LIKE "%car%"

Related

How to save a query result into a column using postgresql

This may be a simple fix but Im somehow drawing a blank. I have this code below, and I want the results that I got from it to be added into their own column in an existing table. How would i go about doing this.
Select full_name, SUM(total) as sum_sales
FROM loyalty
where invoiceyear = 2013
GROUP BY full_name
order by sum_sales DESC;
This leaves me with one column with the name of employee and the second with their sales from that year.
How can i just take these results and add them into a column in addition to the table
Is it as simple as...
Alter table loyalty
Add column "2013 sales"
and then add in some sort of condition?
Any help would be greatly appreciated!
If i got your question right, you need to first alter the table allowing the new field to be null (you can change it later on) then you could use an insert clause to store the value permanently.

SSRS Parameter to select a column name on value which to filter the dataset

I need to allow my user to select a column name and its value from a parameter (or two params) to filter the result.
I have a text parameter with a few column names that are listed in my dataset
Column1, Column2, Column3. Each of those columns has only two values 1 and 0.
I would love some help in getting an idea how to filter my dataset based on the column name listed in the parameter and a selected value (1 or 0)
I assume it has to be related to a dynamic sql but, not sure how to incorporate that in either the WHERE clause or the actual dataset filter.
Thanks for any points guys!! :)
In the tablix you can use the filter section to set the criteria
col1 = param1.This will only select the rows that match the value of the parameter.
https://www.mssqltips.com/sqlservertip/2597/dataset-and-tablix-filtering-in-sql-server-reporting-services/

Two filters on one column with respect to each other

I would like to filter my data source by itself. In SQL it is just INNER JOINNING a table by itself.
For example,
SELECT table1.*
FROM table1 INNER JOIN (SELECT id FROM table1 WHERE variable = ‘X’ AND value = 1) q1 ON table1.id = q1.id
WHERE table1.variable = ‘Y’
As you can see I want to present only the variable which equals ‘Y’ with respect to variable =’X’ and value=1.
I can also write it like this,
SELECT *
FROM table1
WHERE variable = ‘Y’ AND id IN (SELECT id FROM table1 WHERE variable = ‘X’ AND value = 1)
I am using a long data file which means my primary key is 'id' and 'variable' together. So, I want all the variable = ‘Y’ data to be presented only if the 'id' has variable = ‘X’ AND value = 1. How do I translate this process in Tableau dashboard?
Any suggestions on how to do it without inner joining the data source by itself? I tried the inner join way but my data is very large which resulting in too much processing time and it makes all the other processes extremely slow.
First, just point your data source at table1 without any other changes. Plain and simple.
Second, back on a worksheet, select the id field in the datapane and right click to create a set. Choose the all radio button on the general tab of the set dialog pane, and then switch to the condition tab. Define the set via the formula max(variable = 'x' and value = 1). Call your set something meaningful like ids_having_an_X1. This will create a set of ids that have at least one data row matching your condition. Think of it as a list of ids that could go inside a SQL IN (...) clause if that helps
Now you can use your set on the filter shelf to only include those ids in the query, or in calculations, or on other shelves.
To get the effect of your where clause, put variable on the filter shelf choosing only the value 'Y'

FileMaker: How to auto-fill field in a new record with value from different field in previous record

FileMaker Pro Version 11. Two fields of interest in a record: Let's call them start_value and end_value.
When creating a new record I want start_value to be auto-filled with end_value from the previous record (which should be the highest end_value in the table).
I am an old-time C coder, this is my first FileMaker attempt, so be gentle with me. :-)
My last answer was insane . I worked through your problem and found a working solution.
Create a new field maxvalue(Field type = summary ).
.A prompt shows you to find maximum value via checkbox Maximum then Select end_value field
Goto start_value field->field options->auto-enter
Check Calculated value
click specify and write 'maxvalue' without quotes
You can use a cartesian self-relationship and add Auto-Enter calculation to the start_value field definition to be Max(end_value). Max(end_value) have to refer to the related field and not the local one.
===
Added some instructions:
Open Define Database and select the Table Occurrence of the table where fields start_value and end_value are. You can also add another table occurrence of this table for the calculation. Let's call it MyTable.
Duplicate MyTable and give it a name, e.g. MyTable_self
Create a relationship MyTable to MyTable_self, by any field will be fine, but preferably by Primary Key.
Open "Edit Relationship" and change the relationship type from join (=) to cartesian ( x ).
Open the filed definition for start_value in MyTable.
Change Auto-Enter options to "Calculated Value" and add formula
Max(MyTable_self::end_value)
The context of calculations has to be "MyTable"

Microsoft Access 2010 - Foreign Key as Dropdown

I have two tables that I display in a form:
tblUsers -> user_id, firstname, lastname, group_id
tblGroups -> group_id, groupName, groupDesc
I can get the data that I want with:
SELECT tblUsers.firstname, tblUsers.lastname, tblGroups.groupName
FROM tblGroups INNER JOIN tblUsers ON tblGroups.[group_id] = tblUsers.[group_id];
But what I need is a form that shows the user information and a dropdown list for the group but showing the name of the group not the ID and so the group can be changed for a specific user e.g. Manager, Editor etc...
Thanks,
Gareth
Right-click on the ComboBox (assuming it's a ComboBox...) and open the Properties window.
Set the Row Source to:
Select Group_ID, GroupName from tblGroups
Set the Column Count to 2, because you want the combo to store both the ID and the Group name
Set the Column Widths to "0; 2" (without the quotes). This will essentially hide the ID because the column width of the ID field is 0.
Set the Bound Column to 1, because you want to bind to the ID column and not the Group Name column, because the Group ID is easier to query with.
Then you reference the combo with Me!MyComboboxName.Value to get the Group ID.