Topic: How do I group multiple cross related records? Posted: 11 Sep 2013 at 10:49am
I am a newbie to Crystal Reports, so pardon me if my terminology is incorrect or this is really basic. I am running CR 2008 and connecting to Salesforce.com stored procedures (Salesforce reports).
I have two data sets [Loans] and [Assets]. Any given loan record can have any given asset records associated to it. Any given account record can have any loan record related to it. I would like to group related loans and accounts and determine the loan to value (absolute value of the loan divided by the value of the collateral).
Asset 1 and Asset 2 are used as collateral for Loan 1 and Loan 2.
Asset 3 and Asset 4 are used as collateral for Loan 3.
Asset 5 is used as collateral for Loan 4.
In this scenario above I am expecting 3 groups. Each group would have a loan to value of 50%.
I am able to group on loans and assets respectively, but then I get duplicate values whenever there is more than one connection to any given record. i.e if I group on loans, then my assets are double counted. If I group on assets, then my loans are double counted. I would like to total the value of the loans and then total the value of the collateral for any set of related loans and assets.
I was able to create a running total formula that summarized the distinct count for "Loans" and evaluate on change of field "Assets" which is generate the correct "break" points in the data set, but I don't believe it is possible to group on a running total field.
Any thoughts on how one might accomplish creating groups like this? Any help would be most appreciated. Thanks so much.
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 12 Sep 2013 at 9:22am
DBlank will recognize my solution...
a stored proc, that would create an different identifier that would be a 'transaction' this would remove the duplication.
The other solution that pops to mind is subreports...but for them to not suffer from the same issue of duplication would be to again have a 'transaction'.
To be fair, I think that this is the part of the data that DBlank is looking for...is there something that ties all the data together or is that data really like:
asset 1 and 2 are used as collateral on loan1
asset 1 and 2 are used as collateral on loan2
if this is the case, there probably isn't any simple, non-trivial solution to this using CR
one would think that there is a customer tied to both loans and assets, and they hopefully are the same customer. Then you could group by the customer and sum the assets and loans to get the final value.
Thanks for the comments. Here are a few (hopefully) clarifying remarks:
Assets and Liabilities are on a single table in salesforce. A separate table "collateral" allows for the linkage between any asset and any liability. A liability can have more than one linkage to an asset and an asset can have more than one linkage to a liability. The salesforce report for collateral relationship I am referencing in Crystal would have 7 distinct entries like this:
To lockwelle's comment about hopefuly tying to a common customer:
Unfortunately I can't always rely on the customer as a common data point. One asset may be owned by a person and another by a trust/entity in which they have sole ownership. Good idea though! (I got really close with this approach before coming to the forum).
Let me know your thoughts and if you have any additional questions. Again, I really appreciate the help. This forum is great!
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 16 Sep 2013 at 6:23am
I am not sure if Common Table Expressions are valid in a command object, but for a stored proc in Sql Server you could use them to dedupe your data.
something like:
with cte as (
select
rowid = row_number() over (partition by table.assetNo order by table.assetNo),
table.assetNo,
table.loanNo,
any other info you want
from table
)select * from cte where rowid = 1
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum