| Author |
Message |
XCom69
Newbie
Joined: 14 Aug 2012
Location: South Africa
Online Status: Offline
Posts: 7
|

Topic: Crosstab Calculation or Dynamic Columns Posted: 14 Aug 2012 at 4:24am |
|
I have the following data in sql.
Date |Customer|DespatchOrder|Value|ApprovedCredit
08/10|Axe |AGB-01 |50 |200
08/12|Axe |AGB-02 |75 |200
08/13|Axe |AGB-03 |80 |200
08/15|Axe |AGB-04 |10 |200
08/09|Vex |VSE-01 |50 |150
08/10|Vex |VSE-02 |60 |150
08/13|Vex |VSE-03 |40 |150
With some manipulation in sql I have managed to display my data in a crosstab in crystal reports like in the examples below:
AXE
Date |ApprovedCredit|Total|AGB-01|AGB-02|AGB-03|AGB-04
08/09|200 |0 |0 |0 |0 |0
08/10|200 |50 |50 |0 |0 |0
08/11|200 |50 |50 |0 |0 |0
08/12|200 |125 |50 |75 |0 |0
08/13|200 |205 |50 |75 |80 |0
08/14|200 |205 |50 |75 |80 |0
08/15|200 |215 |50 |75 |80 |10
VEX
Date |ApprovedCredit|Total|VSE-01|VSE-02|VSE-03
08/09|120 |50 |50 |0 |0
08/10|120 |110 |50 |60 |0
08/11|120 |110 |50 |60 |0
08/12|120 |110 |50 |60 |0
08/13|120 |150 |50 |60 |40
08/14|120 |150 |50 |60 |40
08/15|120 |150 |50 |60 |40
The problem that I have, I cannot find a way to calculate my overlimit column inside of a crosstab, the over limit is calculated by approvedcredit - Total(Column inside of crosstab)
AXE
Date |ApprovedCredit|Total|OverLimit|AGB-01|AGB-02|AGB-03|AGB-04
08/09|200 |0 |0 |0 |0 |0 |0
08/10|200 |50 |0 |50 |0 |0 |0
08/11|200 |50 |0 |50 |0 |0 |0
08/12|200 |125 |0 |50 |75 |0 |0
08/13|200 |205 |5 |50 |75 |80 |0
08/14|200 |205 |5 |50 |75 |80 |0
08/15|200 |215 |15 |50 |75 |80 |10
VEX
Date |ApprovedCredit|Total|OverLimit|VSE-01|VSE-02|VSE-03
08/09|120 |50 |0 |50 |0 |0
08/10|120 |110 |0 |50 |60 |0
08/11|120 |110 |0 |50 |60 |0
08/12|120 |110 |0 |50 |60 |0
08/13|120 |150 |30 |50 |60 |40
08/14|120 |150 |30 |50 |60 |40
08/15|120 |150 |30 |50 |60 |40
Please help if you have any idea how to do this, I have tried to create my report without a crosstab, but was not successful with the dynamic column headers. I would like to keep on using the crosstab due to the dynamic nature of this report and sometime there can be more than 10 DespatchOrders but if there is no way to do this using a cross tab please help with alternative.
I found away to create the over limit column inside of Crystal Report using a Calculated Member with a value formula
ApprovedCredit - GridValueAt(CurrentRowIndex, 0 ,0)
The GridValueAt function is now supported by crystal reports xi neither is a calculated member. Just another brick wall
|
IP Logged |
|
|
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 14 Aug 2012 at 4:30am |
How are your SQL skills? I can think of a possible way to get the data in the format that you need based on a command rather than using tables in a cross-tab. This would give you the ability to do your calculations as needed as you are not dealing with the limits of the cross-tab. -Dell
|
|
|
IP Logged |
|
XCom69
Newbie
Joined: 14 Aug 2012
Location: South Africa
Online Status: Offline
Posts: 7
|

Posted: 14 Aug 2012 at 4:36am |
|
I have considered to modify my stored proc, but first need to know if crystal can handle this for me. currently my stored proc is large and very slow, don't really want to change anything that will slow down my query any more
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 14 Aug 2012 at 4:49am |
You don't mention what type of database you're connecting to. However, the newer versions of both Oracle and SQL Server now have built in syntax for pivoting data in a query. If you're using either of those two databases, I would recommend looking into that to return the data in an already pivoted format so that you don't have to use a cross-tab. -Dell
|
|
|
IP Logged |
|
XCom69
Newbie
Joined: 14 Aug 2012
Location: South Africa
Online Status: Offline
Posts: 7
|

Posted: 14 Aug 2012 at 5:15am |
|
If you look at my sample data, you will see that in my sample there are 7 different despatchorders, the despatch orders will be where the pivoting need to be done. only problem is that most customer have at least 10 different despatchorders and there are almost a 1000 customers. so I don't think Pivoting in sql would be ideal, due to the dynamic nature of this data
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 14 Aug 2012 at 5:42am |
Then there's probably no way to get what you want in Crystal XI. -Dell
|
|
|
IP Logged |
|
XCom69
Newbie
Joined: 14 Aug 2012
Location: South Africa
Online Status: Offline
Posts: 7
|

Posted: 14 Aug 2012 at 9:47pm |
|
I found some sort of a workaround to my problem, I altered the display string of the Total column, so now it shows my overlimit next to my total. is there any best practices methods how to insert extra line into a crosstab.
|
IP Logged |
|
|
|