Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calculate three fields

Posted on 2013-06-21
5
Medium Priority
?
248 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

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

596 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