Pentaho Report Designer: Passing list of values as parameters to report - sql

Report Objective: Performance analysis of players by statistics comparison
Desired Report Layout
Please refer to the layout and read on. The player names need to be added from a list which could be anything like entry text box, multicheck box, dropdown etc. If I select Jake Tyler in this list, the report should refresh and show me the statistics from him. Then when I select Adam Smith, he should show up as the next entry below Jake with his respective stats.
I know how to pass individual players as parameters in the query using Pentaho parameters and tagging them in the condition using SQL as:
'where PlayerName = ${playername}'
But I need to know how to pass multiple player names in a similar fashion to generate this report using multivalue String parameters.
Can you please please guide me on how to do this? I have heard things like x-actions which could work but I don't know how to use that. I am sure this will help a lot of people who are trying to achieve something similar which might seem complex to them.

You can simply use where PlayerName IN (${playername}).
The list should be correctly passed from the parameter to query.
and the parameter also should get data correctly.
Eg:
select 'Jake Taylor' as pn
union
select 'Adam Smith' as pn
union
select 'Chris Lawson' as pn
or
select distinct column_name from table_name
this can be sent to parameter (in Add parameter window) and your main query can be prepared as I explained above using IN
NB: You can use only Display types like: Multi value list, Multi selection box etc. Not drop downs which pass only single value.

Related

How to disable a link in oracle apex depending on what the value in a column is

I have an interactive report with many columns. One of these columns is employee review. In review the values can be good, bad or not applicable. This column has a link to a form which allows employers to change the review from not applicable to either good or bad. Another column is employees. This employees column has a link to the employee profile. So when an employer logs into oracle apex they can go to this interactive report. Right now i have it set up so that employers can click on the employee name column and go the employee profile and see their details. I want to make it so that once the review is set to good or bad, the link stops working (so that employers can only see employee profiles when they are reviewing them not at any other time).
Im not sure whether this would be a process or validation. I dont think its a dynamic action because it wont let me make a dynamic action based on a column in an interactive report. If possible could someone outline the code i would need to enter in the process to achieve this.
Please let me know if the description is unclear and i will try to change it.
I've been meaning to write a blog post detailing a simple example, but it belongs in your SQL.
select case when col = 'reason to display' then
apex_page.get_url(...)
end as my_col
And define column to not escape special characters.
Or check out slide 58.
If I am understanding it correctly, you want to create a link in emp_Review column.
When Emp_review column having value 'Not Applicable' then display link and open a form otherwise link should be disabled.
You can achieve this in your Interactive Report SQL query only.
You can write below code, assuming the form page number is 2 and having a P2_EMP_Id hidden item created in page 2 to pass the emp_id from page 1 to page 2:
Select EMP_ID, --Or whatever ID column you have
CASE when Emp_review ='Not Applicable' then
'<A HREF=F?P=&APP_ID.:2:&SESSION.::NO:RP,2:P2_EMP_ID:'||EMP_ID||'></A>'
ELSE Emp_review
END Emp_review,
other_column1, --Select other necessary column
Other_column2
from --your table name

Syntax for adding to this T-SQL Query

I built a simple UI for our users to query on our SQL Server DB. The UI started off as just one input field for a person's name. This field's input would be used to search on 3 fields on our database. The query up until now looks like this:
SELECT [Id], [Url], [PersonName], [BusinessName], [DOB], [POB], [Text]
FROM dbo.DataAggregate
WHERE CONTAINS([PersonName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([BusinessName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([Text], 'NEAR((john, doe), 2, FALSE)')
The above assumes the user queried on John Doe. The requirement for NEAR has to do with the format inconsistencies across data in our fields, but that's not relevant to this question, just an FYI.
Now, I've been instructed to add 4 more input fields in the UI to allow users to further tailor their query. These fields already exist in the DB records. My question is how do I add on to the above query for when the additional fields in the UI are used? Am I simply just adding several AND statements to it or OR statements to it?
Let me give an example to help you help me:
User Query:
Person Name: John Doe
DOB: 01/01/1900
Address: 123 Main St
POB: USA
Occupation: Worker
How would I add to my query to include the data for the other 4 input fields? Initially, to handle which input fields are populated and which are not, do I need IF statements in the query?
Each value in the other 4 input fields would need to be searched for in its own field, plus the Text field - i.e.
-The DOB would need to searched for in the DOB field and Text field
-The Address would need to searched for in the Address field and the Text field
etc.
It just seems there has to be a more efficient way to structure a query like this than having basically 5 sections similar to my above query separated by IF/AND/OR.
Thank you.
If you use parameters you can get round unpopulated inputs with this trick
Where
((#input1 is null) or (somefield = #input1))
Or / And
...
This is going to get messy real quick though, they'll come up with more inputs next week.
Other options
Grid with Filter capability.
Data dump for say Excel
Building the query programatically, with parameters.

SQL query / SQL Reporting Services

Been rattling my brain for a while and I could not get pass how to do the SQL query that will show the relationship/connections between my two tables.
I'm working on an IT equipment inventory program. I have two tables;
SELECT serial_number, model, ship_dat, status FROM items_list
SELECT item_serial, connected-to_serial FROM connections
All items like desktops, laptops, monitors, etc are on the items_list table. To track down the relationship/connections of the items, I created the connections table. IE, Monitor with serial_number=Screen#1 is connected to a Desktop with serial_number=Serial#1. It works ok with my Window Form application because I
used a datagridview control to list all devices simple SQL query.
However, when trying to show the relationship/connection on SQL Reports I've ran out of ideas how to do it. I'm aiming to get the report look like below or something along the lines. I just need to show the connections between the items.
Thank you
You should be able to do this with a table in SSRS if that is what you are using. The query you would need to drive the table of all related items would be:
SELECT item_serial, connected-to_serial, mainItem.*, connectedItem.*
FROM connections
INNER JOIN items_list mainItem ON connections.item_serial = items_list.serial_number
INNER JOIN items_list connectedItem ON connections.connected-to_serial = connectedItem.serial_number
You can of course tailor the SELECT statement to your needs, mainItem.* and connectedItem.* will not give you the most descriptive column names. Using column aliases (found under column_alias here) you can give a more descriptive name to each column.
From here you should be able to use a table and create a row group on the main item (either name or serial number) to get the type of look you are looking to achieve here. I believe the Report Wizard actually has most of the functionality you are looking for and should handle the bulk of this. You may have to move some of the cells around to get the look you are going for though.

Possible to return a collection of values when a single value parameter is chosen in SSRS

In a SSRS report, is it possible to return a collection of values when a single value parameter is chosen?
For example, I want to have a parameter Team, with options: "Cardinals, Orioles, Blue Jays".
When a team is selected, I want to return the members of the selected team, so I can do something like
Select Runs
From Baseball.Data
WHERE Player IN (#Team)
Is this possible in Reporting Services or is there a better technique?
Create another parameter #Players and set it as multivalued parameter and internal. Use this expression to populate the parameter.
=Switch(
Parameters!Team.Value="Cardinals",split("CardinaPlayer1,CardinalPlayer2,CardinalPlayer3",","),
Parameters!Team.Value="Orioles",split("OriolesPlayer1,OriolesPlayer2,OriolesPlayer3",","),
Parameters!Team.Value="Blue Jays",split("BlueJaysPlayer1,BlueJaysPlayer2,BlueJaysPlayer3",",")
)
I am supposing #Team is not a multivalue parameter. Replace
CardinalPlayerX, OriolesPlayerX, etc. by the actual name of players.
Now in the query just use the #Players parameter:
Select Runs
From Baseball.Data
WHERE Player IN (#Players)
Let me know if this helps.

Two Datasets one query

I am trying to create a report using two datasets.
The first has a user id which i need to link to the second one to pull the information required. The second dataset query needs the user.id before the query will work Is there anyway i am able to do this.
Thanks
Can you explain your scenario little clear. Are you trying to have a cascaded parameters in SSRS reports? Say, You need to select a Product from the dropdown (Bat, Ball, Nets etc) and depending on the selection another dropdown will be loaded with the relevant data say (For Ball - Basket ball, Volley ball, Foot ball etc)
You will need to create a subreport and from there pass the user id that is returned from the first dataset into the subreports parameter.
If you have not used subreports, here are some articles: (Assuming you are using Crystal Reports)
http://blog.niklasottosson.com/?p=1137