Inserting a calculated column after every column in cross tab, in crystal report 2011
HI,
I want to insert a calculated column after every column i a cross tab . The cross tab shows , sales by region for a number of years , for example from 2007 to 2013. The year can be changed based on the user parameter. How can I do that ?
Thanks
Hi Feroz,
To calculate the Percentage Change and also to show the Percentage sign, here's what you need to do:
1) Right-click the Calculated Column Header > Calculated Member > Edit ColumnValue Formula and use this code:
cdate(1890,01,01)
If the field used as the column is a datetime field, use this:
cdatetime(1890,01,01,0,0,0)
2) Right-click one of the zero values in the Percentage Column and select Calculated Member > Edit Calculation formula and use this code:
if CurrentColumnIndex = 2 then
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex))/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex)
) * 100
else
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex))/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex)
) * 100
3) Right-click one of the Values in the summary cells > Format Field > Number tab > Customize > Currency Symbol tab > Click the formula button beside 'Currency Symbol' and use this code:
If Year(GridRowColumnValue("Date_field")) = 1890 then
"%" else "$"
Note: Replace Date_field with the field name you've used as the Column in the Crosstab. The double-quotes ARE required and you should remove any curly braces that CR adds automatically.
4) You might want to use a similar code in the 'Position' formula too.
Let me know how this goes.
-Abhilash
Similar Messages
-
How to insert horizontal line dynamically after every line item in sapscrip
Hi All,
I have to insert a horizontal line after every new item in sap script.
How to do this .
In some material there is2 line item or in other line item it ay be more .
How to insert horizontal line dynamically after every line item
Point will be rewarded
Regards
NirajHi Niraj,
You can get your work done by keeping the horizontal line (&ULINE&) after all the item level fields, in this case once each item line is written you will get a horizontal line.
In case you have different fields for the item lines which are optional (not printed every time) then you can have them in an IF....ENDIF condition and below the endif use a horizontal line.
Some thing like this:
/E ITEM_HEADER
IL <TI>Item,,Material,,Description</>
IP <TI>,,,,Quantity,,,,Price,,Price unit,,,,,,Value</>
/ &ULINE(71)&
Let me know if this helps, else please describe your problem with an example.
Luck. -
Type mismatch on CRVS2010 appl. after install Crystal Reports 2011
Hi,
I've a Windows application built in VS2010 with Crystal Reports for VS2010 that exports a report to a PDF, Excel or Word file. The application runs fine, but after the installation of Crystal Reports 2011 I got the "Type mismatch" error when the ReportDocument.Export method is called:
System.Runtime.InteropServices.COMException (0x80004005): Type mismatch.
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisioins.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options)
at MyApp.ReportConfig.Execute() ....
HELP!!!!
Uninstalling Crystal Reports 2011 SP1, Crystal Reports 2011, Crystal Reports for Visual Studio 2010 SP1 and Crystal Reports for Visual Studio 2010 (in this order) followed by a re--install of Crystal Reports for Visual Studio 2010 and Crystal Reports for Visual Studio 2010 SP1 does not remove the problem.
Config:
Windows 7 Ultimate x64
Edited by: Adri Koopman on Jul 23, 2011 10:32 AMYes, I asked them to make note also, there have been delays, it was decide to hold off after the info was released and by then it was too late. Once it gets out everyone seems to be able to get it....
So are you having problems installing still or just exporting? If exporting what code are you using?
Have you set your Project for 32 or 64 bit, not anycpu?
What framework are you using, Any of the FULL versions is a must.
Try this sample:
private void ExportToStream_Click(object sender, EventArgs e)
CrystalDecisions.Shared.MicrosoftMailDestinationOptions mailOpts = CrystalDecisions.Shared.ExportOptions.CreateMicrosoftMailDestinationOptions();
CrystalDecisions.Shared.DiskFileDestinationOptions diskOpts = CrystalDecisions.Shared.ExportOptions.CreateDiskFileDestinationOptions();
CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
CrystalDecisions.Shared.CharacterSeparatedValuesFormatOptions csvExpOpts = new CrystalDecisions.Shared.CharacterSeparatedValuesFormatOptions();
CrystalDecisions.Shared.HTMLFormatOptions HTMLExpOpts = new CrystalDecisions.Shared.HTMLFormatOptions();
rpt.Load(@"c:\reports\b.rpt");
diskOpts.DiskFileName = @"c:\reports\worldsales.pdf";
exportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.HTML32;
exportOpts.ExportDestinationOptions = diskOpts;
HTMLExpOpts = new HTMLFormatOptions();
HTMLExpOpts.HTMLEnableSeparatedPages = false;
HTMLExpOpts.UsePageRange = false;
HTMLExpOpts.HTMLHasPageNavigator = false;
System.IO.Stream oStream;
byte[] byteArray = null;
oStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
byteArray = new byte[oStream.Length];
oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
// this is used to verify the file so I saved it to disk
System.IO.File.Create(diskOpts.DiskFileName, Convert.ToInt32(oStream.Length - 1)).Close();
System.IO.File.OpenWrite(diskOpts.DiskFileName).Write(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
System.IO.File.SetAttributes(diskOpts.DiskFileName, System.IO.FileAttributes.Directory);
oStream.Close();
GC.Collect();
MessageBox.Show("Export to Stream complete", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
Don -
Calculated column shows all zeros in cross tab discoverer report
Hi
I have a calculated column in a cross tab report which shows all zeros, but when i duplicate the report as 'table' the calculated colun is getting populated.
i did not understand why it is doing like that, are there any special privileges or any special settings required for creating a cross tab report.Hi,
No there is no special privs for cross tab but there is an aggregation issue.
There are some methods of aggregations used in the discoverer.
First thing you can so is to make sure that in the cross tab sheet you use the detailed data points and that you are not combining different levels of aggregations (for example one amount in details and another one summed).
Second thing you can try is to change the aggregation for this worksheet, you can do that by going to the worksheet properties to the aggregation tab and try to change the settings.
Third thing is to check the pref.txt file in the application server and set "AllowAggregationOverRepeatedValues" to 1
BTW also search your data and find whether you got NULL values in the aggregated items, if so then wrap the data points with NVL function. -
Displaying other columns/tables apart from a cross tab
Hi,
I designed an RTF template. This contains 3 tables. First table contains the invoice information. 2nd table is the cross tab and 3rd table contains the aging details. My requirement is to print the other tables in all pages if the cross tab goes to multiple pages. Presently all the tables are displayed in the 1st page only. If the cross tab output goes to next page then the 1st and 2nd tables are not being displayed in other pages.
Can anyone suggest me how to display the other columns/tables apart from cross tab columns if the cross tab output goes to multiple pages.Can u plz send me the sample xml and the template so tat i can help u frm my side...
-
Suppress Columns shift Cells Lefts in Cross Tabs
Hello All
I need some help getting a cross tab report to suppress data correctly.
I have the following reporting requirement
Based upon Fiscal Year Period Selection report should start from the input period back 24 months.
Example
For the following example I use selection criteria of FY 2008 and period 11
Report should look as follows
2008
11 10 9 8 7 ....
Account Receivable 100 200 300 4000 5000 ....
Where the starting column is the input period 11
The table structure is
Account Number, FY, Key Figure Period 1, Key Figure Period 2, Key Figure Period 3 .... Key Figure Period 12
Parameters
Fiscal Year
Period
Cross Tab Format is
FY
Account Number Key Figure Period 12, Key Figure Period 11, Key Figure Period 10, ... Key Figure Period 1
When conditionally suppressing the field I am using a suppression formual
Key Figure Period 12 = {?FY}="2009" and {?Period}<"12"
Key Figure Period 11 = {?FY}="2009" and {?Period}<"11"
Key Figure Period 10 = {?FY}="2009" and {?Period}<"10"
etc.
The problems is that when I suppress I just get a blank field
2008
12 11 10 9 8 7 ....
Account Receivable 100 200 300 4000 5000 ....
What I want is a complete suppression of the column and commence the report from Period 11 as follows.
2008
11 10 9 8 7 ....
Account Receivable 100 200 300 4000 5000 ....
Can anyone provide tips on how to achieve this?
Thanks
PhillipThanks for your help. Sorry for my wording causing confusion I am new at Crystal Reports. I think I may have caused some confusion for I am actually wanting to stop the summarized data from showing, and shifting the summarized data to the left based upon a selection criteria.
Some more details
The Cross Tab has a Column heading of Fiscal Year.
The summarized values report the contents of fileds GLTO_HSL12 etc and are shown horizontaly with the label showing.
I can suppress the summarized fields so that they wont show. What I am trying to do is get the summarized fields to move to the left if based upon a selection criteria the logic I am applying is as follows
If Fiscal Year is 2009 and period is 10 then show summarized data from field GLT0_HSL10 to GLT0_HSL1 with GLT0_HSL10 being the first summarized field reported.
Currently based upon the Fiscal Year is 2009 and period is 10 example I can only blank out the summarized data for GLT0_HSL12 GLT0_HSL11 the actual format of the cross tab remains static.
Cross Tab Layout
______________________________FY2009
Summarized Data Heading_______| Period 12_____| Period 11 _____| Period 10 | ....Period 1
Row 1_______________________| GLT0_HSL12__|GLT0_HSL11__|GLT0_HSL10__|...
using suprresion formula in summarized fields I can achieve the following
______________________________FY2009
Summarized Data Heading_______| Period 12_____| Period 11 _____| Period 10 | ....Period 1
Row 1_______________________| ____________|________________|GLT0_HSL10__|...
What I want though is
______________________________FY2009
Summarized Data Heading_______| Period 10_____ | Period 9
Row 1_______________________|GLT0_HSL10__|GLT0_HSL09__|...
I hope this explains my problem alittle better.
Phillip -
Calculations based on Summarized data in Cross Tab
First off, I'm pretty experienced with Crystal.
I've run accross something that seems like it should be realy easy to do, and the sort of thing you would expect to do in a cross tab... so maybe I'm missing something totally obvious.
I'm doing a year over year comparison of some financial data broken down by month and by quarter.
So, my Rows are Quarter, and a field called 'YEARMONTH' (calculated field, YYYYMM, for ease of sorting)
My column is Year, and for summarized fields, I have the data field I'm interested in which is a float. Let's call it 'Dollars' for sake of argument.
What I want to do is create a summary field (next to the total field) called 'Difference' or 'Delta' that calculates for reach row the difference between my two years (2008, and 2009)
The only solution I can come up with is to dummy in a record from the datasource with a year value of 'Difference' and some other dummy values so that it will show up as a column on the cross tab, and then somehow use the currentrowcolum function or some such creature to mask the output in the column. but now that I type it out here, I'm not sure it's going to work. I also don't think it's going to export the way I want it to either.
I'd really prefer it to be in a cross tab, and not in some manually created cross-tab emulation using manual running totals, but I'll go there if I have to.
Thanks a ton!This is what I did in my report to get the difference
my crosstab looks like this
2004 2005 Total
Total T1 T2 T
USA A B C
INDIA X Y Z
right click on T1 and go to format field and write the suppress condition like this
numberVar d:=0;
currencyVar array arr1;
currencyVar array arr2;
numberVar e;
if GridRowColumnValue('year')=2004 then
(e:=e+1;
redim preserve arr1[e];
arr1[e]:=CurrentFieldValue)
else
(e:=e+1;
redim preserve arr2[e];
arr2[e]:=CurrentFieldValue);
false
right click on T and go to format field and write the Display string condition like this
currencyVar array arr1;
currencyVar array arr2;
totext(arr1[1]-arr2[1])
right click on A and go to format field and write the suppress condition like this
currencyVar array four;
currencyVar array five;
numberVar d;
if GridRowColumnValue('year')=2004 then
(d:=d+1;
redim preserve four[d];
four[d]:=CurrentFieldValue)
else
(d:=d+1;
redim preserve five[d];
five[d]:=CurrentFieldValue);
false
right click on C and go to format field and write the Display string condition like this
currencyVar array four;
currencyVar array five;
numberVar g;
g:=g+1;
ToText(four[g]-five[g])
Note: Please select the option "column totals on top" for crosstab in customize style
Hope this helps!
Raghavendra -
After installing SP3 for BO XI R1 - Crystal Reports taking forever to run.
Hello,
We are running BO XI R1 SP3. Ever since installing SP3 a number of our scheduled Crystal Reports are taking forever to run. The Business Objects server resources are okay, CPU never really gets above 50% so I figure perhaps it's our SQL Server.
We run SQL 2005 and CPU on that hovers around 30%, we've got 4 2.6GHz CPUs with 16GB of RAM. Looking in SQL Server activity monitor the reason the reports are taking some time is that the wait types are generally CXPACKET.
For example a report used to process in a minute however after installing SP3 the report now takes several hours. Since we've 4 CPU's on our SQL Server activity monitor creates four sessions for the report to try and process it in parallel. However all of those four sessions have a wait type of CXPACKET. This I understand is related to parallelism and people have said to reduce that so nothing runs in parallel.
However I should not have to do that as things used to run just fine, there is no physical reason (i.e. RAM / CPU / HDD) that reports are locked waiting in SQL server. Has anyone else had this issue or have any suggestions on how to fix please?
Kind regards,
Chris RutherfordXIR2 has two different redistributable MSI packages. One is compatable with 1.1 framwork applications and the other is compatable with 2.0 framework applications.
try downloading the SP3 MSIs from [here|https://smpdl.sap-ag.de/~sapidp/012002523100009656792008E/crxir2sp3_net_si.zip]
this will have both MSIs
- CrystalReports11_5_NET.msi (for 1.1fwk applications)
- CrystalReports11_5_net_2005.msi (for 2.0fwk applications)
rename the CrystalReports11_5_net_2005.msi to CrystalRedist115_x86.msi and replace the existing file in the Bootstrapper folder path
Uninstall the last install, rebuild and try your Click-Once install again. This time you should have the 11.5.3700.0 runtime.
Dan -
Crystal report 2011 percentage calculation(Urgent)
All,
I am working on a report which looks like the below.
product>>>>>>> revenue>>>>>>>>> growth percentage
a >>>>>>>>>>> 12 >>>>>> >>>> 48%
b >>>>>>> >>>>>>>13 >>>>>>>> 52%
c >>>>>>>>>>>>> 14 >>>>>>>>>
d>>>>>>>>>>>>>> 16>>>>>>>>>>>>
total >>>>>>> 25 >>>>> 100%
my requirement is to calculate the individual growth percentage of a and b with the total revenue of a and b only.
to be more specific 12 divided by 25 and then 13 divided by 25.
i want these growth percentages in growth percentage column in my report.
I achieved the selective summation of revenue for a and b in the report footer but i am not able to use the total revenue 25 (that i get in the report footer) in the body of the report(detail section) for growth percentage calculation.
I tried using shared variables and global variables but of no use.i am not able to assign the grand total in the footer to a variable in the detail section in order to calculate the growth percentage.
Is there any easy work around to achieve this? need urgent help.
I also tried running totals and stuff but of no use.
Any help would be appreciated.
Reji.
Edited by: reji2011 on Jan 22, 2012 7:32 PMHi Reji,
I'm not sure how you've added 'a' and 'b', however, whatever way it would be, I'm sure it would be a print time formula.
Meaning it is calculated a later stage after all the records are printed. So, you would never be able to use a value in the Report Footer or any Footer to calculate against a detail section value and show the calculation on the detail section itself.
The way I see it, you would need to insert this report as a sub-report, just to calculate a + b, store this value in 'shared variable' and use it for calculations in the Main Report.
So, in the sub-report, where you have your formula that calculates the addition of a and b, just create a shared variable and assign this value to it.
Place the sub-report on the Report Header and in the Main report create a formula that calls the shared variable. You can then use this formula/variable in Main-report's calculations.
Hope this helps!
-Abhilash -
Hi Expert!
I am young of Crystal Report. I have some problems with using cross tab report.
Rows: hour/Floor, Columns: Floor, Summarized Field: Sales
I want to show the result as below:
hour/Floor_____________ Floor1___________Floor2__________Total________Ratio
7h-10h _____________ $500 ___________ $1000 __________$ 1500______75%
10h-13h_______________$200 ___________$300___________$500________ 25%
Total__________________$700___________$1300__________ $2000________100%
I want to add Ratio to show on the right after Total Column.
Can I do like this or not? Or Is there another way to do that with the same result?
Regards,This post looks remarkedly like [Add Column to Cross-tab in Crystal Report|Add Column to Cross-tab in Crystal Report;
Please see it for my replies.
Debi -
Delete column data every 30 days
Hi,
I got a question for you all. I had a BLOB column in my database. I will insert pdf’s into that BLOB column. If I want to delete the data in that BLOB column for every 30 days, what do I need to do? I am looking for some suggestions.
ThanksHello,
Once you created the schedule to delete or purge column after every 30 days or last day of every month. You need to create a job and associate your job to your schedule.
Monthly Schedule runs last day of month at 4:01 AM_
Schedule_
BEGIN
sys.DBMS_SCHEDULER.create_schedule (repeat_interval => 'FREQ=MONTHLY;BYMONTHDAY=-1;BYHOUR=4;BYMINUTE=1;BYSECOND=0',
start_date => SYSTIMESTAMP AT TIME ZONE 'US/Eastern',
comments => 'Monthly_purge',
schedule_name => '"MYUSER"."MONTHLY_PURGE"'
END;
Job to purge or delete colum with above schedule_
BEGIN
sys.DBMS_SCHEDULER.create_job (job_name => '"MYUSER"."MY_DELETE_JOB"',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
Delete from pdf_table where id=''pdf'';
end;',
schedule_name => 'MYUSER.MONTHLY_PURGE',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Delete a blob column every 30 days',
auto_drop => FALSE,
enabled => FALSE
sys.DBMS_SCHEDULER.set_attribute (name => '"MYUSER"."MY_DELETE_JOB"',
attribute => 'job_priority',
VALUE => 2
sys.DBMS_SCHEDULER.set_attribute (name => '"MYUSER"."MY_DELETE_JOB"',
attribute => 'restartable',
VALUE => TRUE
sys.DBMS_SCHEDULER.enable ('"MYUSER"."MY_DELETE_JOB"');
END;Regards -
How to count number of columns in cross-tab report
I have created a cross-tab report and have managed to get the data out as below:
Jan Feb Mar....(display of months will auto expand) Avg/Mo Total
UserA 4 3 4 11
UserB 6 1 1 8
UserC 5 5 5 15
Total 15 9 10 33
I want to insert a calculated column (Avg/Mo) into the cross-tab report based on the formula: Total/Number of Months. I used this calculation formula for Avg.Mo column:
(GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/GetNumColumns)
However, I get the wrong average since GetNumColumns count the total number of columns including the column of Avg/Mo and Total.
How do i get the number of columns, excluding the Avg/Mo calculated column and Total column?
PS: I can't use hardcode since the number of months/columns will auto expand the months progress...
Edited by: jutamind on May 26, 2010 9:27 AMok managed to solve this by slightly changing the formula:
GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/(GetNumColumns-2) -
Dear Friiends,
I would like to write down query which also returns the total of some columns after every 25 records.
like this
ccno salary
1 5000
2 10000
25 80000
total <total of above 25>
26 25000
27 10000
50 13000
total <total of above 50>
can we achieve this
Waiting for reply .with tab as (
select 1 ccno,100 salary from dual union all
select 2 ccno,200 salary from dual union all
select 3 ccno,300 salary from dual union all
select 4 ccno,400 salary from dual union all
select 5 ccno,500 salary from dual union all
select 6 ccno,600 salary from dual union all
select 7 ccno,700 salary from dual
)--end of test data
select ccno,
salary,
case when mod(row_number() over (order by ccno), 3) = 0 then sum(salary) over (order by ccno) else null end as sumsal
from tab
CCNO SALARY SUMSAL
1 100
2 200
3 300 600
4 400
5 500
6 600 2100
7 700
7 rows selectedChange the 3 in the mod to 25 for your data -
How to create a title over the top of the left-most column in a cross-tab.
This is one of those things that seems simple until you try it.
I'm almost there. I moved the cross-tab from the report header to the report footer so I can have a page title. I tried using an overlay but it didn't work for any page past the first.
I can't seem to figure out how to put a title over the left-most column though.
Thanks in advance,
JI have used a text box, after you type in the text, select the box, and move it to the front.
then select the crosstab and move it to the back. -
Cross tab Date Column Grouping
Hi,
I have a cross tab in my report which displays no of tickets opened grouped by day, week or Month, grouping is done based on a parameter GroupBy, which has Day, Week, Month values
Incident Jun -99 Jul-99
Priority1 10 20
Priority2 45 23
if user selects day or week, cross tab should display column in dd/mm/yy format, if its month, MMM-yy format.
I have created formula which returns a date type
GroupBy = Day then Opendate
GroupBy = Week then opendate -dayofweek(opendate)+1
GroupBy = date(year(opendate),month(opendate),1)
and used this date formula as column in cross tab. I tried to format using custom date style...but its not working in cross tab.
if I use totext to format the date formula, data will not be in sorted order...ex, its showing jul-99 before jun-99
can anyone help?
Thanks in Advance,
JyothiYou can avoid multiple cross tabs by using the Display String expression under Field Formatting. The expression that is entered in this field is what is displayed as the field value in the report. Use the same logic as you are using for calculating the value, except return CStr(CurrentFieldValue, <format>), where <format> is the formatting code for the desired date format based on GroupBy.
HTH,
Carl
Maybe you are looking for
-
"object reference not set to an instance of an object" after update datasource lightswitch
I'm using Latest Visual Studio 2013 Ultimate (2013.3) and when I attempt to open "update datasource" it throws an error "Object reference not set to instance of an object."
-
Outlook Safe Senders List GPO not working
Hi I followed These instruction https://social.technet.microsoft.com/Forums/office/en-US/c0714d7d-2a42-4b0f-9f1d-63234c7278a0/appending-outlook-safe-senders-list-via-gpo but my Safe Senders List still not applied Any ideas? My Environment Office 2010
-
I have a HP Pavillion desktop running windows 7. It's a pc and monitor in one. My computer is running hot. I vacummed the vents then used a cotton swab to clean the outside of the vents and I also am using a seperate fan to blow cool air on it. Is th
-
I switched to outlook instead of hotmail, and I downloaded firefox as instructed, but each time I sign in to my email account it comes up download firefox now or continue on without, I want the firefox but am unsure how to get it to go....why do I ke
-
Disable/hide Command Field in T-iViews
Hi All, I have ctreatd some transaction iviews. I am using SAP GUI type as SAP GUI for windows, I there any way to disable/hide the command field so that user user cannot enter any other T-Code and navigate to that transaction. Waiting for your input