Hopefully the title says it all.. But just in case. I am in the midst of reworking some custom-built in-house software, written in vb.net, that queries the database, gathers the returned data and processes it within the vb.net, then outputs the results to Crystal Reports to display.
We have found this to be incredibility wasteful of resources, and cruelly slow. Like I mentioned before I am reworking this program so that the Crystal Report itself gathers the information and displays it. This morning I am reworking a seemingly simple portion, a Monthly Report that just counts the total records, sums somethings and other small tasks.
So my question is this, what is the crystal syntax to count the number of records that is returned, that is between two dates.(parameters that are passed in from the vb side)
I want to write this:
COUNT({Table.Column} in {?FromDate} to {?ToDate});
Crystal Reports then highlights everything inside the count and tells me a field is required here.
I also tried to create a running total, but it only tallied 1. So if that is the correct course of action please explain.
Thanks!!
Crystal reports formula syntax does not allow for a conditional count in this way. I usually perform this sort of thing with two separate formulas: The first populates 1 or 0 for the logic test, the second sums the first, e.g.
{#InRange}:
if {Table.Column} in {?FromDate} to {?ToDate} then 1 else 0
{#sumInRange}:
sum({#InRange}
I'm pretty sure I've achieved similar results in a single formula, but it makes the code less readable and harder to maintain, sometimes requiring While Printing commands that make the formula results inaccessible for use in other areas of the report. Using two formulas also allows for easy filtering on this first one.
Related
ok so I have this report I have to write in SSRS with a very specific format. It looks like the screenshot below at the bottom. Ignore the arrows and colors. It's pulling from an Oracle database. Each number value cell in this table/matrix has a different sql query to pull it in because they come from different tables, etc.
the top half of the numbers in the table are each from a query. the bottom half of the table is all calculations from the numbers in the top half. I already have the queries for the top half and was trying to figure out how I could just use those to make this table in SSRS with just those and then creating calculations in the bottom half for the report. I can't use a table or a matrix because each query is a different dataset and you can only have one dataset per tablix.
I was thinking maybe doing textboxes and drawing the grid manually, which would be a huge pain. I get errors about not having an aggregate and being out of scope or something and haven't figured out the reason for this yet as it is not my ideal solution.
My current solultion that will eventually get me there is unioning every single query and then creating columns with static values for the rows and columns in the grid and turning it into a matrix. Problem with this is it continues to increase in complexity as I create each further down the table calculation, and the code becomes larger and larger, and takes a long time to create, and I have to do like 6 reports similar in nature to the format of this one. Will probably be a thousand lines of sql and force me to have to make a stored proc because of the ssrs character limitation.;
So my question in a more simple way is, how can I take multiple sql queries that return a static value and make them a single value in a tablix that doesn't repeat, then create more blank rows in that tablix that are calculations of other cells values, i.e. Textbox1 - textbox2, textbox3/textbox4 ?
I got it figured out using expressions with multiple datasets. The answer seemed too easy once I found it. Basically just created a table tablix using my first dataset. Created more detail rows with insert row inside group below. Then I went to the expression builder for each one and found the other dataset and double clicked it to get the expression to pull from the other dataset. For example the bac_labor dataset value would look like this. =Sum(Fields!BAC_LABOR.Value, "BAC_Labor")
Then for calculations can use either same thing like =Sum(Fields!BAC_LABOR.Value, "BAC_Labor") + Sum(Fields!BAC_LABOR_OVERHEAD.Value, "BAC_Labor") or could do something like this =ReportItems!Textbox2.Value - ReportItems!Textbox1.Value to reference a cell value. This saves a ton of time, development effort, and reduction of code for calculations, compared to adding together 500 character select statements to make calculations. Also no need to use stored procs and union or join every select statement together with this method.
I need to add a field to a SSRS report. I tried modifying the dataset (query) but the results prouduced insane results, with zipcodes showing up in the name fields and names showing up in a datetime field. I suspect it is because of the groups but I don't understand how they work. The Dataset is created by 4 selects. The first 3 insert into temp tables and the fourth pulls from it. I suspect that I will have to re-write the query but it would be nice if I could use it as is with modifications. Either way I need to understand the groups.
I read
Data Region Cells, Data Region and Understanding Groups. Aside from the fact that they use terms specific to SSRS without defining them they are so undetailed I doubt many people who do not already understand SSRS can get anything out of them.
I did not write this report but I must modify it. I understand SQL well. Not so much with SSRS.
Can anyone explain how to find out what the Row Groups mean? Mine look like this:
Here is the tablix
I have a problem during creating a crystal report which will show a part of one manufacturing process.
So, I need your help....
I have a four different components that forms a one bigger component (or product). Every of this small components pass through different production operations, but the same component don't pass through all production production operations.
And, I need a crystal report which shows every article (component) with a number of finished component in each operation.
Here is the example of SQL result (ordery by operations):
so, you can see that article with articleID = '29183' is going through first and last operation... also, articleID = '17275' is going through the second and last operation... I think that is all clear from the picture...
And, all I need is report that this will show in the columns like this:
In the report, I made a group by ArticleID, so the article (component) appears only in one row... And after that, I need a values in columns (columns for operations) which correspond to every article...
Very thanks... I try this solve for a few days, but I don't know how to solve this... I tried crosstabs, dictionaries, lists but nothing helps me
You've already grouped by Article ID so that each article has its own single line, so that's a good start. Now, you just need to separate the 3 operations with 3 formulas and aggregate them to the group level.
For example, the formula for the first operation would look like:
//If row is a "first operation" then display the finished data element
if {table.Operation}="first operation" then {table.Finished}
Then to display in the Group Footer you could just use a max() summary function on the formula you just created.
I have a very simple task. I have two datsets. The first is a single value that has returned me a number of calls that has been made. The second is a list of targets. I want to be able to divide the first number of calls by its call target in order to calculate the total %.
The lookups of these are dependant on the criteria that is selected in the report itself. I know it's possible to do inside SQL its just a huge pain in the ass. I want to be able to calculate two fields and I thought something so simple would be a breeze for SSRS but apparently not. So the error i get is:
*The expression used for the calculated field'=fields!DMCP.Value / FIRST(Fields!DMCTarget.Value,"AllTargets")' includes an aggregate,rownumber,runningvalue, previous or lookup function. aggregate,rownumber,runningvalue, previous and lookup functions cannot be used in calculated field expressions.*
I can take the first function out but it doesn't help me. It says it can only calculate in the same dataset, problem is these values can never co-exist in the same dataset. Anything I can do????
Thanks in advance
I know crystal reports has 3 phases when it renders a report, and depending on the phase it may read static data or grouped data fields etc, but is there any benefit writing formulas in any of these phases? The end result should always be the same if I specify the phase or not?
The end result will not always be the same and omitting evaluation time functions can sometimes lead to incorrect results. For example, consider that you have a report that is grouped and that you are trying to calculate simple subtotals for these groups with a variable. Say you are resetting the variable in the group header and displaying it in the footer while updating it in the details section via:
numbervar subtotal;
subtotal := subtotal + {table.numericvalue}
Crystal will evaluate this formula while reading records and before the records are in a predictable, grouped, and sorted order. It's not until the second pass, the whileprintingrecords pass, that records have been grouped and sorted. That's why group selection happens in this pass.
This is just one example, but there are a number of ways to break a report by omitting evaluation time functions, mostly having to do with using variables (at least that I can think of). Here is a great resource for details on Crystal's multiple passes: The Multi-Pass Reporting Process of the Crystal Reports Engine