?
Solved

Calculate three fields

Posted on 2013-06-21
5
Medium Priority
?
246 Views
Last Modified: 2013-06-24
Running CR 10

Looking for profitability using 3 fields. Two fields are in one table and one is another, all display currency records. One of the fields only returns currency when it has data otherwise its blank which is causing problems trying to calculate using the other fields. Below are the fields and sample data:

tblSO.sellprice
tblSO.cost
tblsubcontractor.cost

                           sellprice   socost    subcost
SO No. 12345   $200.00    $100.00  $50.00                
SO No. 23456   $100.00    $0.00      
SO No. 34567   $300.00    $100.00  $100.00

I need to calculate the profit using the fields but because SO No 23456 is blank the formula I'm using is not calculating correctly. Using the formula below shows a profit of $100.00 (seems to only be using the last row instead of all three) should be a total profit of $250.00.

{tblSO.sellprice} - ({tblSO.cost} + {tblsubcontractor.cost})

Formula is used in GH1 (tblSO.sonumber) and RFa
0
Comment
Question by:BERITM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 39267457
In the formula editor there is a drop down.  The default setting is EXCEPTION FOR NULLS
Change that to DEFAULT VALUE FOR NULLS

The other way to handle this is to use formulas for the values or NULL tests in the sum formula

Formula SellPrice

If IsNull({tblSO.sellprice}) then
    0
Else
    {tblSO.sellprice}

Formula Cost
If IsNull({tblSO.cost}) then
   0
Else
   {tblSO.cost}

Formula ContractorCost
If IsNull({tblsubcontractor.cost}) then
   0
Else
   {tblsubcontractor.cost}

Your sum formula changes to

{@SellPrice}  -  ({@Cost} + {@ContractorCost})


You can also do this in a single formula

Local CurrencyVar total;
If NOT IsNull({tblSO.sellprice}) then
    total := total + {tblSO.sellprice};

If NOT IsNull({tblSO.cost}) then
    total := total + {tblSO.cost};

If NOT IsNull({tblsubcontractor.cost}) then
    total := total + {tblsubcontractor.cost};

Total

mlmcc
0
 
LVL 35

Expert Comment

by:James0628
ID: 39267913
mlmcc,

 The last formula should be subtracting the costs, right?

 James
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39268260
Actually the last 2 should be subtracting

Local CurrencyVar total;
If NOT IsNull({tblSO.sellprice}) then
    total := total + {tblSO.sellprice};

If NOT IsNull({tblSO.cost}) then
    total := total - {tblSO.cost};

If NOT IsNull({tblsubcontractor.cost}) then
    total := total - {tblsubcontractor.cost};

Total

Open in new window

0
 
LVL 35

Expert Comment

by:James0628
ID: 39268654
Yeah, that's what I meant ("costs" was referring to both cost fields).

 James
0
 

Author Closing Comment

by:BERITM
ID: 39271899
Thank you very much, the formula worked perfectly!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 2 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question