Solved

Calculate three fields

Posted on 2013-06-21
5
244 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 100

Accepted Solution

by:
mlmcc earned 500 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 100

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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