Print Page | Close Window

Select and sum specific totals on Cross tab

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7495
Printed Date: 02 May 2024 at 6:01am


Topic: Select and sum specific totals on Cross tab
Posted By: Crystal Method
Subject: Select and sum specific totals on Cross tab
Date Posted: 26 Aug 2009 at 8:19am
Hi,    I have created a cross tab with a maximum of 6 rows = Manufacturing locations (fields named B,F,M,R,S & V) and a maximum of 4 columns = Market Sectors (named 1,2,3,4 for ease).
I need to select 2 totals from the manufacturing location totals (lines(B) and (V)) and show these as a separate summed value.
Is this possible?
I am using Crystal 8.5 in the guise of InforREPORTS.


-------------
Seagate Crystal Reports 8.5.0.389 in the guise of INFOR:Reports as part of Infor:COM ERP software.



Replies:
Posted By: Crystal Method
Date Posted: 27 Aug 2009 at 4:16am
I've decided that the only solution is to re-enter the whole query as a sub report, selecting on 'B' and 'V' only.
This seems to me to be a long-winded method of getting to an apparently simple task.  Does anyone have a simpler solution.  Here's the orginal sql on which the xtab is based.
 
SELECT
    RELFB."STATUS1", RELFB."STATUS2",
    RELEA."SATZART", RELEA."FIRMENNR", RELEA."ARTIKELNR", RELEA."BEZEICHNUNG", RELEA."EDATUM", RELEA."EJAHR", RELEA."EMONAT", RELEA."ETAG", RELEA."ANR", RELEA."MENGE", RELEA."ME", RELEA."UMSATZ", RELEA."AGKNZ1", RELEA."STATUS2",
    RELFIRMA."KTXT", RELFIRMA."FGKNZ_1"
FROM
    "INFOR"."RELFB" RELFB,
    "INFOR"."RELEA" RELEA,
    "INFOR"."RELADRESSE" RELADRESSE,
    "INFOR"."RELFIRMA" RELFIRMA
WHERE
    RELFB."RNR" = RELEA."RNR" AND
    RELFB."ADRNR2" = RELADRESSE."ADRESSENR" AND
    RELADRESSE."FIRMANR" = RELFIRMA."FIRMANR" AND
    RELEA."SATZART" = 'ABA' 
    RELFB."STATUS1" = 'L'
ORDER BY
     RELEA."STATUS2" ASC
 
The new criteria would select "STATUS2" as one of either 'B' or 'V', and create a grand total.  Is there a solution without using the sub-report option?


-------------
Seagate Crystal Reports 8.5.0.389 in the guise of INFOR:Reports as part of Infor:COM ERP software.


Posted By: DBlank
Date Posted: 27 Aug 2009 at 7:40am
2 options I can think of, just not sure how they will work in the CT.
1. You can use a Running Totals to get the value. Conditionally SUM the values using a formula...{table.field} in ["b","v"] ... for record inclusion.
2. Create a formula field that will allow you to get the sum and use the field n your CT.
If {table.field} in ["b","v"] then {table.valuefield} else 0


Posted By: Crystal Method
Date Posted: 27 Aug 2009 at 8:24am
Thanks DBlank,
 
I created a formula called @forBVSum
If {RELFB.STATUS2} in ["B","V"] then {RELEA.UMSATZ} else 0
 
I added this to the Summarized Fields section, and the correct value is given where the the Total column and Total row intersect. Smile
 
Unfortunately, there are subtotals for each column entry where the row=B or row=V ( and 0s where rows are not 'B','V').  Is there anyway of suppressing the subtotals and zeros?


-------------
Seagate Crystal Reports 8.5.0.389 in the guise of INFOR:Reports as part of Infor:COM ERP software.


Posted By: DBlank
Date Posted: 27 Aug 2009 at 8:36am

For the Zero's,

right click on any field in the cell and select Fromat Field.
Click on the Number Tab
Click on Customize button
check the Suppress if Zero as True (upper left corner)
Save close all windows.
This must be doen seperately for totals.
 
For the subtotals here is from Help files
 
 
 


Posted By: DBlank
Date Posted: 27 Aug 2009 at 8:42am
Here is another link for conditional formating in specific cells based on values...
http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6798 - http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6798


Posted By: Crystal Method
Date Posted: 27 Aug 2009 at 8:56am
DB, You're good!
 
I suppressed zeros as you said.
 
My CR 8.5 doesn't have Cross-tab expert so...
I right clicked each subtotal I didn't want.  Tab 'Common'.  Checked the Suppress box.
The total I did want at the intersection, I only want for company 'L' so I suppressed using the formula:
not ({?Company} = 'L')
Just need to add a conditionally suppressed label to the new subtotal and my work here is done Star 


-------------
Seagate Crystal Reports 8.5.0.389 in the guise of INFOR:Reports as part of Infor:COM ERP software.



Print Page | Close Window