JReport :Subreport query should filter based on sublink? - subreport

I am trying to create a report with subreport in it but I am getting error while executing sbreport query.
The main table shows the details of employee and subquery shows the detail of leaves for each month for each employee.
I have created a subquery where I am selecting all details from the table.
What my issue is:
When I am creating a subquery it should filter based on the sublink.
For example each row in the main report will represent an employee. If the sublink between main report and subreport is employee id, then the subquery should filter the detail based on the sublink.
i.e. if the subquery is
"select employee_id, noOfLeaves from Employee_Detail"
then while executing it should execute like
select employee_id, noOfLeaves from Employee_Detail where employee_id = 151 (where employee_id = 151 is the row from the main report)
Is there any setting in JDesigner where I can make the changes to get this.
I am using Version 10 JERntServer and JDesigner.

You should be able to right click on the subreport or embedded component and select Format Subreport or Link Properties and in the Field tab select the BandedObject in the Component edit box then select Field (Primary) = Field (Subreport) with employee_id of both reports. Be sure both reports contain employee_id.

Related

Reports based on multiple tables MSAccess

I designed a report(salary slip) with many controls(text boxes) in MSAccess 2016.
There are 2 tables Employee details and salary details.
Some controls that need data from employee details table and some from salary table.
I have 2 primary keys
Sl.No
Employee id
for both the tables.
and I have connected the employee id through relationship.
How to specify the expression in the text boxes so that i get the record that matches both the table?
Use a query as record source of your report instead of a table. Then you don't need any expressions in the textboxes, just the column names. I usually give the query the same name as the report but with another prefix. E.g. for report rptSalary the query is named qrptSalary.
SELECT * FROM
Employee E
LEFT JOIN SalaryDetails S
ON E.EmployeeID = S.EmployeeID
In the report, you can insert group headers and footers. You would use EmployeeID as grouping column. Then you can place the employee fields in the employee group header, the salary details in the details section and any sums in the group footer.

SSRS Count Record Based on Field Value (Status) in a Group

I have the data table below:
--> Click here for the picture.
I want to add new column and count how times an employee is present in the office something like this:
--> Click here for the picture.
How can I count it in expression given that I have group in Employee.
Thank you.
You can use LookupSet() function to get the In-Office count. Add a tablix with the Employee Name group.
Note the Days Worked column is inside the Employee group scope but outside the details group scope.
Use this expression to get the count of Attendance In-Office per employee:
=LookupSet(Fields!Employee.Value & "-" & "In-Office",
Fields!Employee.Value & "-" & Fields!Attendance.Value,
Fields!Attendance.Value,"DataSetName"
).Length
Replace DataSetName by the actual name of your dataset. It will produce the below tablix:
UPDATE: Based on OP's comment.
Replace the LookupSet expression and use this instead to add multiple criteria to the filtered count.
=COUNT(IIF(Fields!Attendance.Value="In-Office" OR
Fields!Attendance.Value="Out for Official Business",
Fields!Attendance.Value,Nothing))
It counts In-Office and Out for Official Business rows in the given group.
Let me know if this helps.
You can do it via SQL script.
SELECT A.EMPLOYEE_NAME,A.DATE,A.ATTENDANCE,B.DAYS_WORKED
FROM TABLE A
LEFT JOIN
(SELECT EMPLOYEE_NAME,COUNT(ATTENDANCE) DAYS_WORKED
FROM (
SELECT EMPLOYEE_NAME,DATE,ATTENDANCE
FROM TABLE
WHERE ATTENDANCE = 'IN-OFFICE')
) B
ON A.EMPLOYEE_NAME = B.EMPLOYEE_NAME
You now have the Field DAYS_WORKED then just add it to your table.
=Count(Fields!EmployeeName.Value,"DataSet1")

Access 2013 design report for tow table

I have two tables Main, and Department
Main Table
issue_id
observation
action
date
close Yes/No
Department Table
id (auto increment)
issue_id
Department name
I want to create a report that display the issue from Main table and then display all department that have relation to the issue.
I tried to do it, it display the issue and then one department then display the same issue with different department
You need to add a group in your Report Designer.
Refer to the image below where hilighted.
Add your Issue_Id column as a group.
Display your Issue_Id information in the group section and the Department information in the details section.

How to show data in column in SSRS

I'm using SSRS for my reporting, my reporting solution is in Visual Studio 2008 Business Intelligence Development Studio.
I have a report in which the data should be displayed in this format.
I have added a Column Group in my table which is having the values of Customer Name and details, the data is coming fine in the vertical format i.e column after column.
My Issue :
There should be only three columns in each row, after three records the next row should begin and again not more than three records should be displayed as shown in the image above.
My attempts :
I tried to add a row group and in that gave the expression
= Ceiling(Fields!Row_Count.Value/3)
here Row_Count is a field which is coming from my query which holds the serial number of the records.
My SQl Query
SELECT Row_Number() over(order by table_ID) AS Row_Count, Field_1,Field_2 from MyTable
In my Column group i have Customer Name and in my Row Group i have other details of the customer. The data is getting populated column wise but the issue is its not breaking the current row after three records.
Below is my table of report.
You were on the right track. Say you have data like this:
I have created a tablix like this:
The Row Group expression is:
=Ceiling(Fields!Row_Count.Value / 3)
This works together with the Column Group expression to split over three columns:
=(Fields!Row_Count.Value - 1) Mod 3
The other thing to note compared to your tablix is that CustomerName is not in a table header row, but rather there are two row header rows, one for CustomerName and one for Details.
This is looking OK to me, obviously you can format to taste:

How to reference value from a drop down selection box ...?

I'm using Oracle APEX and I'm generating an interactive report .. Now I have a drop down selection box which has a list of values (LOVs) .. What I want to do is to use the currently selected value in the drop down box in the SQL query being used to generate the interactive report .. Like for example this is the SQL query for generating the interactive report to only show employees with rank Salesman:
select "EMP"."EMPNO" as "EMPNO",
"EMP"."ENAME" as "ENAME",
"EMP"."RANK" as "RANK",
from "EMP" "EMP"
where "EMP"."RANK" = 'SALESMAN'
The above query completely works for me ... Now I have a drop down box on the same page in APEX which is named RANKS, and has this LOV: SALESMAN, CLERK, ACCOUNTANT, DEPTHEAD
How do I change the SQL Query so that it now looks up the currently selected rank in the ranks drop down list and then only displays employees with that rank ...
If your ranks LOV is called P1_RANKS for example, then you can change the query SQL to:
select empno, ename, rank
from emp
where rank = :P1_RANKS
However, that only works once a rank has been selected. If you want to show all employees when no rank has been selected do this:
select empno, ename, rank
from emp
where (:P1_RANKS is null or rank = :P1_RANKS)
You can either make the select list submit the page to refresh the report or, preferably, create a dynamic action to refresh the report when the select list item is changed.

Resources