Selective Grouping in Crystal Reports - crystal-reports

In Crystal Reports 2013, I am developing a financial report that has multiple levels of grouping:
Company Group (a collection of properties)
Company (an individual property)
Division (a group of departments that make up a division)
Account Group (i.e. Revenue, Labor Costs, Operating Expenses, etc.)
Account Sub-Group (just an additional break down of Account Group)
Account Name (The name of a particular account range)
And this all works fine. However, I was given a change request for the report specifying that the level 6 grouping should be variable based on the level 4 grouping (i.e. If Account Group = Revenue then Account Name; if Account Group = Labor Costs then Department Name [IT, Accounting, etc]).
I have tried adding in a group 7 as the Department Name, conditionally suppressing Group 6 based on Group 4, but what happens is that in the groups where it is using the Department Name group (7), the department names are repeated for each Account Name. If I move the groups so that Department Name is 6 and Account Name is 7, then I have the problem in the one group is reporting off of the Account Name.
Here is a screen grab of the report structure with out the additional grouping, no repetition:
Here is a screen grab of the repetition that occurs when Department Name is used as group 7:
Finally, here is a grab of the repetition that occurs if Department Name is used as group 6:
My question is, how can I selectively group the report on either Account Name or Department Name (based on Account Group) without repeating the group type?
I know that this is an issue caused by the hierarchy of the grouping (i.e. multiple departments can use a single account type) so I need to figure out how to have the two groups at an equal level, with some sort of formula/code to decide which one to use.

Actually your approach is wrong....you can't split a group by making it a subgroup of the original group (group 6 and group 7)
You need to write a simple if condition and change the group. For group 6 write formula as below and group using that formula
If account="revenue"
Then account name
Else if account= "labour"
Then department
Create the 6th group with this formula,this automatically change the group6 display as per the account group

Related

Jaspersoft Studio subtotal from amount shown on group header

I have data that is "filtered" through three groups.
First group is defined by departments, second is defined by course id and third is for individual class session id (i.e. room and schedule). Also the source query is giving me the list of all students for each class session, and this causes that the other columns get repeated for every student (i.e. credits per course, total enrollment per session, total students dropped per session, total students auditing per session, etc).
When you drop any of those query counts on the report group's footer the sum is not correct. For example if we have 10 students for a session our sum is 100 enrollment. I want to count 10 enrolled students only once.
The amounts are not shown multiple times because I placed the fields on the group header. So on every group break the row of data is displayed only once.
I believe I need a custom running total and not the default created when you drag and drop the field on the group's footer.
I got something working.
On the report Outline I right clicked on 'Variables' and 'Create Variable'.
For example for the audit count I did the following:
Named my variable 'sum_au'
Value Class Name set to java.math.BigDecimal
Calculation set to Sum
Expression set to the query field for the audit total 'AU': $F{AU}
Increment Type set to [Group]GroupBy_CRN
Reset Type set to [Group]GroupBy_CrseNum
All other fields left untouched (default values)
Once this variable is created you can drag and drop it to the CrseNum Group Footer and it will add the values only once per break on the course session id (CRN).
I will reproduce this for the other values to see if this solution is consistent...

Grouping formula to account for two fields

Working with vehicle asset management and I am selecting data based on two statements:
({EQ_MAIN.PROCST_PROC_STATUS} in ["A", "AS", "AT"] and
{EQ_MAIN.DEPT_DEPT_CODE} like "P*" and
{EQ_MAIN.ASSET_TYPE} <> "COMPONENT")
or
({EQ_MAIN.PROCST_PROC_STATUS} in ["TA"] and
{EQ_MAIN.DEPT_TEMP_LOANED_TO} like "P*" and
{EQ_MAIN.ASSET_TYPE} <> "COMPONENT")
Basically, if the Equipment is in status A, AS, or AT and belongs to the departments that start with P, I want it to show on the report. However, the second part of the selection statement accounts for equipment that is temporarily loaned to another department (status TA). The selection statements seem to be working fine.
I have this data grouped by {EQ_MAIN.DEPT_DEPT_CODE}. But I want it to to include any temporarily loaned out equipment under the department group, if the equipment is on temp loan to said department. For example, Car A belongs to department K1234, but is on loan to department P5678. I want Car A to show up under the group for P5678 along with all the other vehicles that belong to P5678. Essentially, whether a piece of eq belongs to a specific department or is simply on loan to said specific department, I want to see them under the same group in Crystal. Thoughts?
I do not believe that a grouping formula is the solution for this scenario. The challenge is based in the recordset. Since there is only one LOANED_TO record per DEPT_CODE, you can go about this a couple of ways.
If this is an option, modify your query or view so that you generate all LOANED_TO records for each DEPT_CODE. This could be achieved by placing a subquery in your FROM clause if using SQL. Then, join your parent table EQ_MAIN to the subquery on a non-unique, general key. Since there is no one-to-one relationship in this scenario, you should get all LOANED_TO records for each DEPT_CODE. This will, however, bloat your recordset and mar performance.
Then, group the report first on {DEPT_CODE} and second on {LOANED_TO}. Use a suppression formula on the second group to hide any {LOANED_TO} Departments that do not match the parent group {DEPT_CODE}.
The more "traditional" Crystal approach is to group on {DEPT_CODE}. Then, add a sub report to a group section. Using the same datasource, move the second chunk of selection criteria (following the OR clause) to the sub report record selection. This will return all {LOANED_TO} records. Add a sub report link between the group {DEPT_CODE} and the sub report {LOANED_TO} dept. This will filter results to just those {LOANED_TO} records related to the main group.

SQL Server Reporting Services - Custom security module

Take the following two scenarios:-
Developer A has created a set of reports:-
Report A shows details of Audi car sales
Report B shows details of Mercedes car sales
Report C shows details of Volvo car sales, and so on for each of 30+ manufacturers.
So we have 30 report files (.rpt).
Developer A has done this so he can assign different security permissions to each AD group of users:-
Group A can only see Audi car sales,
Group B can only see Mercedes car sales,
Group C can only see Volvo car sales, and so on.
Developer B has taken a different approach:-
She has created a single report (one .rpt file) that accepts a 'manufacturer' parameter in order to display the data for any manufacturer.
In both scenarios the reports are loaded from a report 'menu'. In the first scenario a hyperlink for each manufacturer takes you to the relevant report. In the second scenario the same hyperlink supplies the manufacturer name to the single report as a parameter.
The downside with this scenario is the single report file cannot be locked down to a specific set of users. If the report was locked down to Group A, then Group B or C could not view it at all.
Onto the question:-
In order for us to make the second scenario viable we would need a way of checking to see if the current user, or the current users group has access to view the data they are requesting.
I was thinking of using a custom function, something like CheckAccess(Username,Manufacturer) that returns a true or false, and depending on the return value either redirect the user to load the report, or to an error page respectively.
Another option would be to set up roles for each manufacturer, then assign the roles to each group of people. Could a custom function then be used to check if 'Bill' has the 'Audi' role ??
Looking for ideas here as to the best approach.
I suggest you:
Create a table with the userid and report parameter in it. This way the security of the user access can be managed.
Then use the ssrs User!UserID reference as a parameter in your query.
As an added benefit you can create a query to only populate the manufacturers the active user is allowed to see.

SSRS 2008 R2 - Group toggle aggregates

I'm working with a dataset where employee utilization is calculated as (Time Billed to X/Standard Billable hours). As such, to get the total billable percentage for an employee, I can just sum up the percentages billed to each client. However, I also want to be able to see the percentage of time billed by department.
I've currently got my data in a matrix with row groups Department-->Employee-->Client with 1 column group of "time sheet ending date". When I toggle the visibility of the client row group based on the employee row group, I get the correct totals at the client and the employee level. However, when I toggle the visibility of the employee row group based on the department row group, the department row group has the wrong totals. For example, if Department A has employee B with 90% utilization and employee C with 95% utilization, the toggled total at the department level is 185%....However, I am expecting to see 92.5%....any ideas????
You might just need to tweak the expression used to get the department total. I am unsure what expression exactly you used, but it should be of the form:
SUM(epmployeePercentageColumn)/COUNT(employeePercentageColumn)
obviously replace the "employeePercentageColumn" with whatever field or variable or expression that represents each of the employee percentages that come under the particular department.
If your current expression isn't in that form, try and tweak it.
Hope it Helps.

How to get distinct values from a none relation FileMaker Pro database

I have a FileMaker Pro database the was create by another person when the created it years ago it was not relational. It has many contacts and each contact is assigned to a single group. I want to get a distict list of those groups from that database. So if I started with say
group 1
group 1
group 2
group 3
group 7
group 3
I would end up with just groups 1,2,3,and 7 once each
than I can import them into the new database to make it relational so one contact can belong to more than one group
but I can't seem to figure out how to get that list. If someone could help I would appreciate it.
Sort by group, then export into, say, tab-separated file, and in the export dialog check the "group by" flag for the group field. The resulting file will have only distinct groups.