Calculating a Number in a Cross-Tab
Not sure the best way to explain this one, but I was helped to create a cross-tab that used an array to calculate the number of incentives and summarize the result in a cross-tab. Now I'm looking to take this number and multiple it by another column in a table {UnitCost} to calculate the total value of the incentives used for the report.
The previous issue was here:
Problems with running totals
For instance, if the units costs are as follows:
Double Fandango = 10
Fandango = 5
Gift Card $10 = 10
Movie Ticket = 5
I would like to cross tab to look like the attached picture. Would this be possible?
The array formula is:
whileprintingrecords;
stringvar d:= {OBI_EquipmentMaster.Description};
numbervar p:= {DriveProjectionAndCollectedTotals.ProcedureProjection};
numbervar pe:= {DriveProjectionAndCollectedTotals.ProceduresPerformed};
stringvar array ad;
numbervar array ap;
numbervar array ape;
numbervar c2:= 1;
numbervar n:=0;
// check to see if the description has been added to the string array
// if not, add it plus add the initial projection value to the number arrays
if not (d in ad) then
numbervar c:= c + 1;
redim preserve ad[c]; ad[c]:= d;
redim preserve ap[c]; ap[c]:= p;
redim preserve ape[c]; ape[c]:= pe;
else
// if the description is already in the array, find its position
// then add the new projection as a running total to the appropriate number array values
while c2 <= count(ad) do
if d = ad[c2] then (n := c2; exit while);
c2 := c2 + 1
ap[n]:= ap[n] + p;
ape[n]:= ape[n] + pe;
// grand running totals
numbervar gp:= gp + p;
numbervar gpe:= gpe + pe;
I thought it would be a start creating a new number variable:
numbervar i:= {OBI_EquipmentMaster.UnitCost}
But I'm not sure I understand the rest of the formula nor how to insert a new column in the cross-tab. Any suggestions on how to proceed?
Thanks,
hi Trey,
since you're using the Display String in your first summary you need to assign the displayed value to a variable. i.e. change the Display String formula to
whileprintingrecords;
stringvar t:= GridRowColumnValue ("rpt_EquipmentMaster.Description");
stringvar array ad;
numbervar array ap;
numbervar c3:= 1;
numbervar n2;
while c3 <= count(ad) do
if t = ad[c3] then (n2 := c3; exit while);
c3 := c3 + 1
numbervar apn:= ap[n2];
totext(apn,0)
once that is done, you now have a variable (apn) that is available on the row level for your summaries.
once you've added the unit cost field as a Maximum type summary to your cross-tab as the second summary, right click on that summary and go to the display string for unit cost maximum. enter in this syntax:
whileprintingrecords;
numbervar apn;
numbervar apnrt:= apnrt + apn*currentfieldvalue;
totext(currentfieldvalue * apn,0)
note that you're referencing the variable apn which is used in the output of the previous summary. also note that you're creating another running total named apnrt which runs in the background of the cross-tab. you'll need this running total for the grand total in the cross-tab.
now right click on the grand total for the maximum unit cost summary and go to the display string for this value. enter in this syntax.
whileprintingrecords;
numbervar apnrt;
totext(apnrt, 0)
Similar Messages
-
Count from Cross TAB1 should add to Line Number in Cross TAB 2 in 1 report
Hello Friends I have 2 cross Tab1 based on 2 query data providers. I need to feed calculate the Count of Items in Cross Tab1 and add that to line Number in Cross TAB2 which sit below cross tab1
So if there are 21 items in Cross TAB1 then Line Number in Cross TAB 2 shall be 22
so do this i Created a count variable
=Count([Item ID]) In Report
which give me 21 in cross tab1 but when I drag that to cross tab2 it give junk value 179
so How do I fix this Line number Count in Cross Tab 2
Please help with code to say Count([Item ID]) In Report from cross tab1 and add Line Number to it = 22
thanks
soniyaHello Friends I have cross Tab1 and Cross Tab2 based on 2 query data providers. I need to feed calculate the Count of Items in Cross Tab1 and DISPLAY In cross Tab2
Dimension name is ITEM ID
So if there are 21 items in Cross TAB1 then in Cross TAB 2
I want to display "Number of Item" = 21
so do this i Created a count variable
=Count([Item ID]) In Report
which give me 21 in cross tab1 but when I drag that to cross tab2 it give me count of Item in Cross Tab2 = 87 which is wrong since i want 21
so How do I fix this Count in Cross Tab 2
Please help with code to say Count([Item ID]) In Report from cross tab1
thanks
Soniya -
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) -
Format Fields in Cross Tab and Calculated Members
Hello:
I have a cross Tab with a calculated member, I need to display one decimal or no decimal in some of the columns so I created a formula in the Display String option like this:
if GridRowColumnValue ("@TestID_desc")= "ALK mg/L
then
Cstr(CurrentFieldValue, "0")
else
Cstr(CurrentFieldValue, "0.0")
But, after I saved the formula the value in the calculated member colums disappears. Any ideas? Thank You in advance!right click on calculated field and go to format field and in number tab select customize button and write the condition for decimals.
regards,
Raghavendra -
Calculated Members in a Cross Tab
I have a Cross Tab report with Year as the Column Headers and Product Name as the Row Headers with Sales as the Summarized Field. There are 5 Year values (e.g. 2004 to 2009 Inclusive) and I have created 5 new Calculated Member columns that do comparisons between consecutive years. Everything works fine.
However, the report is parameter driven for the Year range and if I choose a new range (e.g. 2000 to 2004) different than my current range (e.g. 2004 to 2009) this causes all my Calcuated Member columns to disappear.
Is there a way to keep the 5 Calculated Member columns I created whenever I change the range of Years?
I do not want to resort to a Mock Cross Tab.
Any help would be appreciated. Thanks in advance.David,
If your parameter for the years were a starting year number, you could base all your calculations on it.
for example starting year=X
then data selected would be between Year(X) and Year(X)+4
And your column calcuations would be for years X, X1, X2, X3, X4
Debi -
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 ?
ThanksHi 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 -
Cross Tab calculation in Individual column-Crystal Report
Hi experts
I am preparing a report in Crystal report 2008. Report template is Cross Tab.
Structure of report is
Cardname-Row, DocType-Columnd, DocTotal-Summarize field.
Result of this report is
IN(Invoice) RC(Incoming Payment) Total
XYZ 1000 -500 500
ABC 2000 -1000 1000
Total 3000 -1500 1500
I have inserted a column using calculated member. I want to Calculate in that column with BP opening balance
eg. OCRD.Balance-DocTotal when I do this it give first value to all column rows, i.e (consider XYZ opng Balance is 1500, I have calculate month opening balance which meance Current Opening Balance-Current month Order bookings=Month opening balance)
IN(Invoice) RC(Inc Pmt) Total Opng Balance
XYZ 1000 -500 500 500
ABC 2000 -1000 1000 500
Total 3000 -1500 1500 500
I want to calculate Opng Balance for each CardName but it gives first Customers opning balance to all customers.
Give me solution.
Thanks in AdvanceHi
I think you can do calculation based on the formula .On the cross tab ,there is :
X -selection - row
Y - selection -column
Z - summary
You can also use formula on cross tab to do that function and insert into summary section .
Hope this helps .
Bishal -
Calculated members in cross tab
Hi all,
I have a profit and losses in a cross tab created by a group and I need to add some rows to have the totals.
For example
Revenue 1
Revenue 2
Revenue 3
Total Revenue
Cost 1
Cost 2
Total Costs
For total revenue I used a calculated members with that formula:
GridValueAt(GetRowPathIndexOf("Revenue 1"), CurrentColumnIndex, CurrentSummaryIndex)
+ GridValueAt(GetRowPathIndexOf("Revenue 2"), CurrentColumnIndex, CurrentSummaryIndex)
+ GridValueAt(GetRowPathIndexOf("Revenue 3"), CurrentColumnIndex, CurrentSummaryIndex)
but the problem is that if I haven't for example any data for revenue 2 an error occurs -->argument # 1of "gridvalueat" is out of range.
It's possible to check if the argument exist??
thankshi alessandro,
i just found your forum post in the unanswered list...hopefully you've already found the answer for this.
GetRowPathIndexOf is looking for the text in a specific cell and not the actuall Row or Column Name.
When it doesn't find it, its output is -1...so you can use that in your formula to ensure that it doesn't break.
for example, if you have a cross-tab that looks like
Canada 1006
USA 5555
Mexico 2331
GetRowPathIndexOf("Mexico") = 2 (as the index starts at 0 for Canada)
GetRowPathIndexOf("Brazil") = -1
hope this helps,
jamie -
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 -
Bug – CR 2011 cross tab number decimal formula not executing
I have a formula to format the number of decimal points in both the column and row header values in a cross tab subreport. The formula does not appear to execute. If I display the data in a simple table format and use the same decimal formula the format is correct.
cross tab header, decimals not displayed correctly
Data when displayed in a simple table using the same formula, decimals are displayed correctlyHi Paul,
Here's another way:
Remove the formula you've used under 'Decimal' for the cells in the crosstab.
Right-click one of the cells > Format Field > Common tab > Click the formula button beside 'Display String' and use this code:
numbervar x := CurrentFieldValue;
numbervar ipart;
numbervar decpart;
ipart := int(x) ;
decpart := x - ipart;
if ipart > 0 then
totext(ipart,0)
else if decpart > 0 then
Replace(totext(decpart),"0","")
-Abhilash -
How to insert page number on each page for Cross-Tab report?
Hi,
I have created a Cross-Tab in the section Report Header via Crystal Reports 11.
Now, I want to created more Cross-Tabs, and each page has one Cross-Tab.
So, I insert Report Headers to contain Cross-Tabs. But, the report only shows the page number at the last page.
How to insert page number on each page?
Thanks in advance.Hi,
Well, the easiest solution is to place the Cross-tab in the Report Footer, Of course, ONLY if the report contains this single object which I'm assuming is not the case.
If you do not wish to place the cros-tab in the Report Footer, here's what you need to do:
1) Create a formula;
whilereadingrecords;
2) Create a group on this formula. If the report already contains groups, move this formula to the top of the grouping list. It won't affect the other groups or records in any way.
3) Move the Cross-tab from the Report Header to the Group Header1 and suppress Group Footer1
4) Add the Page Number field to the Page Footer
Let me know how this goes!
-Abhilash -
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. -
CR 2011 - calculated member in cross tab
Hello,
I have created a cross tab in my report and added a calculated member. I have created a formula for all my rows because by default the value of the calculated member was "0". Now I wanted to add a new row to my report. The value in the calculated member now is not "0" but empty. How can I access the formula workshop now?
Can anybody help?
Thanks and regards,
Juleif you right click on the cross-tab > go to Advanced Calculations > Calculated Member > click on the one that you want to edit and press the Edit Value Formula button
cheers,
jamie -
Formatting Calculated values in Cross Tab
I have a P & L Style cross tab where I have inserted calculated values to calcuate the key % values (Turnover, Overheads etc).
I have used the "Quotient" calculations & bet the correct data, but I would like to format the values to show as %> When I try to change these values, all the values show as %.
Is there any way to achieve what I need?
ThanksThanks for that, it would have been easier than the way I found, which was using the display string in the field formatting.
I might have another pass at it now.
Much appreciated -
Cross Tab Column Header and Embedded or Calculated Member
Hello All
I am needing some help with a Cross Tab in CR2008.
My Cross Tab look as follows:
Rows______________Columns
......................................Fiscal Year
Account Number...........Summarized Field (Value Field)
The report spans three Fiscal Years but not all accounts have three Fiscal Years worth of data so some Cross tabs start 2009, 2008, 2007, Some report 2008 and 2007, Some just 2007 (and other variations). To get my cross tab working correctly I need to create a formula that get the CurrentColumnIndex based upon the Fiscal Year. e.g. If columnd header = 2009 column index = 0.
Can anyone advise how I would go about this?
Thanks
PhillipPhillip, go to your data source, and see if you can add a new connection,
one of those options should be (Command)
if you can add a Command, then you can put the SQL in the command section.
You will need to add the Command as a data source, and remove the old
data source once the command is added, you will be able to edit it if needed.
Maybe you are looking for
-
Cannot have more than one Mobile item for a person
Hi, I cannot have more than one mobile phone item for a person. In India some of them carry dual SIM card phones and both will be valid. In Lumia 800, I dont see an option to add two mobile items. I can do with a work around by choosing one mobile it
-
I have tried the obvious....CP and made sure the correct printer was selected and it wasn't set to print to file. I then did the about:config and reset the printer. I have also updated all the plugins with none of the solutions working. Please help..
-
USB TV tuner software for OS X?
I just bought a USB TV tuner, and right now I have to boot my Mac Pro into boot camp in order to use it. Is there some kind of software for OS X that I can use so that I don't have to do that? EDIT: I found EyeTV, but I would rather have something t
-
SerialVersionUID's not matching
Hi, here's my exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.io.InvalidClassException: com.tsc.model.courts.Co
-
Hi, I saw a post on this question from Jan '06, but the answer was in php not asp. The question is: How do I go about adding a link to a MP3 file so that when it is clicked on, it does not play in the visitor's default music player, but brings up the