Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Fill in missing financial accounts Post Reply Post New Topic
Author Message
Alex
Newbie
Newbie


Joined: 28 Jan 2008
Location: Canada
Online Status: Offline
Posts: 22
Quote Alex Replybullet Topic: Fill in missing financial accounts
    Posted: 11 Aug 2008 at 7:16am
I am working on budget report which is supposed to display posted budget amounts and also posted actuals for selected accounts (trough account category) and selected periods. So far everything works fine except there are some accounts that have no postings in either table (budget and actual) and those accounts don't get displayed (which is expected). But, user want to be able to see these acounts as well (with zero budget and zero for actual for selected period). Any idea how to achive this? Here is my SQL statement entered in command:
select
     b.account_cat_id,
      b.description,
     a.entity_id,
     a.budget_id,
     a.account_id,
     a.debit_amount BUDGET,
     a.posting_date,
     0 ACTUAL
from
     ledger_account_budget a,
     ledger_account b,
     ledger_account_category c
where
     a.entity_id = 'CORP' and
     a.posting_date >={?BeginDate} and
     a.posting_date <={?EndDate} and
     a.currency_id='CDN' and
     b.entity_id = a.entity_id and
     b.account_id = a.account_id and
     c.id = a.account_cat_id and
     c.account_class in( 'EXP', 'ASSET')
union all
select
       b.account_cat_id,
       b.description,
      a.entity_id,
      a.budget_id,
     a.account_id,
     a.credit_amount BUDGET,
     a.posting_date,
     0 ACTUAL
from
     ledger_account_budget a,
     ledger_account b,
     ledger_account_category c
where
     a.entity_id = 'CORP' and
      a.posting_date >={?BeginDate} and
     a.posting_date<={?EndDate} and
      a.currency_id='CDN' and
     b.entity_id = a.entity_id and
     b.account_id = a.account_id and
     c.id = a.account_cat_id and
     c.account_class not in( 'EXP', 'ASSET')
union all
select
     b.account_cat_id,
     b.description,
     a.entity_id,
      ' ',
     a.account_id,
     0,
      a.posting_date,
     a.debit_amount - a.credit_amount ACTUAL
 
from
     ledger_account_balance a,
     ledger_account b
where
     a.entity_id = 'CORP' and
     a.posting_date> ={?BeginDate} and
     a.posting_date< ={?EndDate} and
      a.currency_id='CDN'  and
     b.entity_id = a.entity_id and
     b.account_id = a.account_id
 
 


Edited by BrianBischof - 12 Aug 2008 at 6:46am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 12 Aug 2008 at 6:50am

The only way to get the information displayed on the report is to get the missing data into the resultset. Since the data doesn't exist, you need to create it. I assume you have an account table, so do a select from it which returns the accounts which don't have data in the budget or actual table. I would do a SELECT statement from the accounts table where NOT EXISTS account in either table. I did a similar sql statement last week where I put the original table (from the UNION statement) into a temporary table and then check that the account does not exist in this temporary table and return the accounts with zero amounts.

Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Alex
Newbie
Newbie


Joined: 28 Jan 2008
Location: Canada
Online Status: Offline
Posts: 22
Quote Alex Replybullet Posted: 13 Aug 2008 at 8:51am
Thanks Brian.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.016 seconds.