Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
friendz am stuck at a point that in crystal Crosstab report, i need to have sum of only two column's value and subtract the total by the value what should i do?

as in below,

C#
        Product 1    Product2    Product 3    Total
        ----------------------------------
Cust 1      4           5           2          11
Cust 2      5           9           7          19


I want to sum values of "Product 1","Product 3". then subtract from row total=> Total LIKE [4+2]-11=>TOtal. and want to repeate this for each customer..

the way which I using to solve is.....[this is basicly C.R formating Display String Formula with VB Syntax]

C#
Global totprodsum as int

Global Ccust As String 
Dim Ldept As String 
Whileprintingrecords
if (Ccust="") then
    totprodsum=0
    totprodsum=totprodsum+currentfieldvalue
    Ccust=gridrowcolumnvalue("Table_Customer.Name")
    formula=currentfieldvalue
else
    if Ccust<>gridrowcolumnvalue("Table_Customer.Name") then
        totprodsum=0
        totprodsum=totprodsum+currentfieldvalue
    else
        totprodsum=totprodsum+currentfieldvalue
        formula="Newag"
    end if
formula=currentfieldvalue

end if

Ccust=gridrowcolumnvalue("Table_Customer.Name")


but its not working bacause Crystal report generates report in this sequence

Cust 1 <1st col value>

then.....

Cust 2 <1st Col Value>

then..........

Cust 1 <1st col value> <2nd Col Value>
Cust 2 <1st Col Value>

then ....

Cust 1 <1st col value> <2nd Col Value>
Cust 2 <1st Col Value> <2nd Col Value>

then .....

Cust 1 <1st col value> <2nd Col Value> <3rd Col Value>
Cust 2 <1st Col Value> <2nd Col Value>

then..

Cust 1 <1st col value> <2nd Col Value> <3rd Col Value>
Cust 2 <1st Col Value> <2nd Col Value> <3rd Col Value>

while I want crystal report to Execute report like this

Cust 1 <1.1> <1.2> <1.3>

then......

Cust 2 <2.1> <2.2> <2.3>


anyone please help me out.
Posted
Updated 15-Apr-13 1:46am
v3
Comments
Aarti Meswania 15-Apr-13 4:25am    
you mean yo have product 1 & 3 and total now you want to find value of product2???
wajahatabdi 15-Apr-13 7:37am    
I want to sum values of Prod1 & prod3 and then subtruct them by Total
Maciej Los 15-Apr-13 16:12pm    
Still not clear...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900