Sort a group with specified value at the end - crystal-reports

I'm trying to order a group in Crystal Reports 2016, with a value that should be shown at the end of the group.
For example, these are the values (strings) from the group:
B
A
C
D
E
I want to put "C" at the end and the rest ascending, like this:
A
B
D
E
C
My SQL expression is already sorting it in the desired order, but that doesn't work.
I tried it with "Specified Order", but the value C would be the first record.
Also the formula on Groupoptions for sorting with checkbox "Use Formula for Groupordering.." doesn't work for me, because i can't even select the databasefield...
(I'm using the german version of crystal reports, the exact description of the elements may be different)
How could i get this to work?

If your query already returns the correct order , just use "in original order." instead of specified

Related

How to use Maximum in Crystal reports

i want to filter my rows and only select/ display my rows when the field AMSD135.AB is the latest date date in that group.
So i got a report with some groups where the last group is grouped on AMSD135.AB. Now i created a formula to hide the section.
AMSD135.AB <> Maximum({AMSD135.AB}, {AMSD135.AB})
but i always get the following error message:
There must be a group that matches this field.
if i use
AMSD135.AB <> Maximum({AMSD135.AB})
it searches for the max in all rows.
It works when i use the following formula:
{AMSD135.AB} <> Maximum({AMSD135.AB},{Arbeitsgang.AGNR})
with {Arbeitsgang.AGN} being the group above. Which makes more sense, since when i group by AB, Max(AB) is always AB. But shouldnt it still work.

Custom Sort in Crystal Reports

We have a report that has one group. The group header is based on a (rather extensive) formula which says if the item number is equal to "AAAAAA" then the header should read one of the following:
Conduit
Metal Flex
Copper Wire
Aluminum Wire
Aluminum SE
SO Cord
SQ D
Breakers
etc.
Currently, the groups are sorted in alphabetical order when the report is run. How can we change this so it prints in the order we want (for example as above)?
On the "Use a Formula as Group Sort Order" formula, it says we can only return the group sort order constants as Ascending, Descending or Original order. I tried Original Order seeing as how the group formula is set up in the order wanted, but it still does it in alpha order.
If you are using the field from database to group then you can use option "Group in Specified order" and there provide the order you want to view.
You can get the option if you go to change group.

Converting decimal to char Reporting Service 2005

I'm developing a Report Server on SSRS 2005. In this report there are some clause contracts. Just one of this clauses isn't constant, so sometimes it appears and sometimes doesn't. It will appear if a column value on one of my datasets isn't null,
Every clause must be preceeded by a char and a Parentheses. For example, the first clause must be preceeded by a), the second by b), the third by c)...
The problem is, that clause that can be shown or not, if shown, must be the clause a and the other constant clauses must follow it. But if the variable clause doesn't appear, the first constant clause must be the a clause.
I tought the following. On the sql code of my dataset I made a case when test to check the column that indicates if the clause will appear or not, if it's null, the clause will not appear and I return on the select of my dataset the integer value 96, if it is not null, the clause will appear and I return on the select of my dataset the integer value 97.
I want to convert this integer value to a char. So 97 will become an a.
I'm using the report server element TextBox to receive this integer value, so I want to do somenthing like this.
=Convert.ToChar(First(Fields!FIRSTLETTER.Value, "DataSetAditionalInformation"))
I use Convert.ToChar(value) in C#, and I want to know the equivalent command to use on my Report Server.
On the first constant clause on my report I want to do the following:
=Convert.ToChar(First(Fields!FIRSTLETTER.Value + 1, "DataSetAditionalInformation"))
And for each constant clause, I will increase by one the number after the plus signal.
So, if the variable clause appears, the FIRSTLETTER will be 97, and the second clause will be 98, after converting these number will become the letters a and b. If the variable clause doesn't appear, the FIRSTLETTER will be 96, and the first and constant clause will be 97, and after converting: a.
I don't even know if this is possible, so any idea will be appreciated to solve this problem.
Thanks in advance.
UPDATE
A example of how the contract clauses will work:
I have this select:
SELECT CASE WHEN ADDITIONAL_CLAUSE IS NULL THEN 96 ELSE 97 END AS FIRST_LETTER,
ADDITIONAL_CLAUSE
FROM TBLADDITIONALDATA
WHERE (NUMBER_CONTRACT = #NUMBER_CONTRACT)
If the select returns 96 (and this means that there isn't an additional clause), the clauses will be like below:
a) The amount of monthly contemplations will be defined in accord to the disponibility of the credit of the group on the respective month of the Meeting Group realization.
b) The total amount of plots are not constants, because them are calculated in accord with the variation of the object price
If the select returns 97 (and this means that there is an additional clause), the clauses will be like below:
a) The text of this clause isn't constant, it depends of the value stored in the column ADDITIONAL_CLAUSE
b) The amount of monthly contemplations will be defined in accord to the disponibility of the credit of the group on the respective month of the Meeting Group realization.
c) The total amount of plots are not constants, because them are calculated in accord with the variation of the object price
I have a lot of other constant clauses, but I guess they are not necessary to exemplify.
So I need to make the letters that preeceed the clauses be not constant, so every letter will be a text box.
The textbox of the additional clause will just appear if the ADDITIONAL_CLAUSE isn't null, this I already did on the Visibility Expression of the textbox. And this textbox receives the value of FIRST_LETTER.
But the other textboxes of every constant clauses will receive the value of FIRST_LETTER plus 1 for the first constant clause, plus 2 for the second constant clause, plus 3 for the third constant clause and so on. But the value of FIRST_LETTER is an integer, so I need to convert it to char.
Thanks again.

Conditional Formula Bombs Crystal Report

I have an issue with one of my crystal reports and it's conditional formula. The formula is shown below. I have two tables that hold different customer info that link to my invhdr table. when the account code is cash I need to retrieve a field from one table and visa versa.. The trouble is crystal seems to ignore the conditional formula as written below and seems to require that a link to the field exists even though the formula should prevent the requirement to retrieve the field..
can anyone explain a possible workaround. maybe a conditional table link if it's possible? Thanks ND
if Len("" + {invhdr.ACCT}) > 0 then
if {invhdr.ACCT} = 'CASH' then {CashCust.CUSTOM1}
else if {invhdr.ACCT} <> 'CASH' then {Lookup.VATREGNO}
else "";
so say if invhdr.ACCT ='test' it seems to still need a link to {CashCust.CUSTOM1}
all my tables are linked as inner join , not enforced
I suggest changing the inner joins to left outer joins (from the invhdr table to the CashCust and Lookup tables, so that invhdr is on the inside of the joins). This is unrelated to the formula - if you have inner joined all three tables, then corresponding records must exist on all three tables for rows to be returned; this is the definition of an inner join.
You may then encounter issues with the formula if invhdr.ACCT is null - a quirk of older versions of Crystal was that if any part of a formula evaluated to null, then the whole formula evaluated to null. This behaviour may have been amended in more recent versions of Crystal, but if not then "" + {invhdr.ACCT} may evaluate as null - try checking the value with the IsNull function instead.

Multiple Groups in jasper reports

I want to create multiple groups in ireport, and the data should display in a group-wise manner.For Eg:
First the Group1 data should be printed completely, then,
Group1:
Module Data
After this i want to print the Group2 data completely
Group2:
Category data
I am using the Result Set datasource.
Can Someone help me in this?
Jasper reports will work exactly in this manner as long as your query results are ordered properly.
For example, let's say you are grouping by a field called "MY_GROUP" and it has values "GROUP A" and "GROUP B". In your report you will create a group for field "MY_GROUP". In your query, make sure you have MY_GROUP as the first field in your ORDER BY clause. You can also accomplish this in iReports by adding the "MY_GROUP" field as your the first field in the Sort Options section of the Report query.
Now that you have added your group and are ordering properly your results will come out like this:
Header - GROUP A
Detail - GROUP A
Footer - GROUP A
Header - GROUP B
Detail - GROUP B
Footer - GROUP B
Exactly as you wish. My guess is that you were not properly ordering your query results. This could result in having multiple groupings for GROUP A, GROUP B, etc. all interspersed.
If groups in iReport don't keep all the data together, use subreports. When Jasper gets to a subreport, it runs the whole subreport and puts the whole thing into the report. You could have something like:
Subreport 1 - Group 1
Group 1 first record
Group 1 second record
Group 1 third record
...
Group 1 last record
Subreport 2 - Group 2
Group 2 first record
Group 2 second record
Group 2 third record
...
Group 2 third record
It's exactly as Tom said. Jasper Reports Groups do not order the data retrieved from the query, they just take it in the order it comes.
In order to display the information in a group-wise manner, you have to add an ORDER BY to the query so the rows the report receives are already ordered.
So there is an issue that happens when you use multiple group headers. The first header behaves like expected ordered by Column Value A only on unique values. The 2nd header using Column Value B will print on every row despite being non-unique values.
In theory you should be able to use ORDER BY:
ORDER BY ValueA, ValueB
to properly display the report assuming you are using sql, plsql, etc... However, in my case that did not happen, though for others it seems to work.
Use subreports to attach the minor differences via unique reports. You create a root report with empty details. Then you create Unique reports to serve as sub reprots. Finally, you use the subreport element to link the values into the root report. Though that is a good bit of work and may cause repeat code.
A hacky way I used was: A mixture of "Print When Expressions" with logical boolean expressions with 2 group headers and a column header.
Boolean Expressions:
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("QueryA") && $P{P_parameter} == null)
and
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("P_QueryA") && $P{P_parameter} != null)
with two group headers and a column header. The column header will not repeat for every row so you assign one of the booleans expressions to it's "print when" so it does not always print. The first group header will not repeat for every row and works. The 2nd group header is used for the times you DO want it to repeat for every unique value since it always prints for every row, and you use the other boolean on it's "print when". Hope it helps