Query "Sum"

B

Bob Vance

If my query has these 2 fields in it "Total Due" and "Paid Amount" what
expression do I use to get "Total Due" Minus "Paid Amount"
 
K

Klatuu

You use a Calculated Field in your query. In the Query builder where you
put the name of the field, you make up a name followed by a colon, then you
put in the expression. It would look like this:

AmountRemaining: [Total Due] - [Paid Amount]

The name AmountRemaining is only an example. Use any name you want.
 
B

Bob Vance

Oops Got it
Payable:
Nz(qTotalDueForPayment.TotalDue,0)-Nz(qPaidAmountForPayment.PaidTotal,0)
 
B

Bob Vance

Because TotalDue is an expression of a sum that is creating a problem
Thanks Bob

SELECT tblInvoice.OwnerID, Sum(tblInvoice.OwnerPercentAmount) AS TotalDue,
qPaidAmountForPayment.PaidTotal, Max(tblInvoice.InvoiceDate) AS
MaxOfInvoiceDate
FROM tblInvoice LEFT JOIN qPaidAmountForPayment ON tblInvoice.OwnerID =
qPaidAmountForPayment.OwnerID
GROUP BY tblInvoice.OwnerID, qPaidAmountForPayment.PaidTotal
ORDER BY tblInvoice.OwnerID;

Klatuu said:
You use a Calculated Field in your query. In the Query builder where you
put the name of the field, you make up a name followed by a colon, then
you put in the expression. It would look like this:

AmountRemaining: [Total Due] - [Paid Amount]

The name AmountRemaining is only an example. Use any name you want.

Bob Vance said:
If my query has these 2 fields in it "Total Due" and "Paid Amount" what
expression do I use to get "Total Due" Minus "Paid Amount"
 
K

Klatuu

Glad you got it working, but in the future, you get more accurate answers if
you include all the information in the original post.

Bob Vance said:
Because TotalDue is an expression of a sum that is creating a problem
Thanks Bob

SELECT tblInvoice.OwnerID, Sum(tblInvoice.OwnerPercentAmount) AS TotalDue,
qPaidAmountForPayment.PaidTotal, Max(tblInvoice.InvoiceDate) AS
MaxOfInvoiceDate
FROM tblInvoice LEFT JOIN qPaidAmountForPayment ON tblInvoice.OwnerID =
qPaidAmountForPayment.OwnerID
GROUP BY tblInvoice.OwnerID, qPaidAmountForPayment.PaidTotal
ORDER BY tblInvoice.OwnerID;

Klatuu said:
You use a Calculated Field in your query. In the Query builder where you
put the name of the field, you make up a name followed by a colon, then
you put in the expression. It would look like this:

AmountRemaining: [Total Due] - [Paid Amount]

The name AmountRemaining is only an example. Use any name you want.

Bob Vance said:
If my query has these 2 fields in it "Total Due" and "Paid Amount"
what expression do I use to get "Total Due" Minus "Paid Amount"
 
B

Bob Vance

I had to make a new query because one of the fields was a sum

SELECT qTotalDueForPaymentOne.OwnerID, qTotalDueForPaymentOne.TotalDue,
qTotalDueForPaymentOne.PaidTotal, qTotalDueForPaymentOne.MaxOfInvoiceDate,
[TotalDue]-[PaidTotal] AS AmountRemaining
FROM qTotalDueForPaymentOne;
Thanks Klatuu

Klatuu said:
Glad you got it working, but in the future, you get more accurate answers
if you include all the information in the original post.

Bob Vance said:
Because TotalDue is an expression of a sum that is creating a problem
Thanks Bob

SELECT tblInvoice.OwnerID, Sum(tblInvoice.OwnerPercentAmount) AS
TotalDue, qPaidAmountForPayment.PaidTotal, Max(tblInvoice.InvoiceDate) AS
MaxOfInvoiceDate
FROM tblInvoice LEFT JOIN qPaidAmountForPayment ON tblInvoice.OwnerID =
qPaidAmountForPayment.OwnerID
GROUP BY tblInvoice.OwnerID, qPaidAmountForPayment.PaidTotal
ORDER BY tblInvoice.OwnerID;

Klatuu said:
You use a Calculated Field in your query. In the Query builder where
you put the name of the field, you make up a name followed by a colon,
then you put in the expression. It would look like this:

AmountRemaining: [Total Due] - [Paid Amount]

The name AmountRemaining is only an example. Use any name you want.


If my query has these 2 fields in it "Total Due" and "Paid Amount"
what expression do I use to get "Total Due" Minus "Paid Amount"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top