casting number as currency in expression

miconian

Well-known Member
Joined
Aug 18, 2004
Messages
769
So basically, there are two important fields: [SumOfNet Amount] and [Accrual Amount]. They are both data type 'number,' field size 'double.' I want to subtract one from the other, and I want the data type for the result to be 'currency.'

Here's how I'm trying to do it:

SELECT [joint estimates with exclusions].*, Format([SumOfNet Amount]-[Accrual Amount],"Currency") AS [Revenue Loss]
FROM [joint estimates with exclusions] RIGHT JOIN [problem-campaign-only] ON [joint estimates with exclusions].[Capture ID] = [problem-campaign-only].[Capture ID]
WHERE (((Format([SumOfNet Amount]-[Accrual Amount],"Currency"))>0));

But this results in a data type mismatch. What am I doing wrong?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
The FORMAT function actually returns Strings, not Numbers, so you do not want to use that in the middle of mathematical functions.

So I think you need to change this:
Code:
WHERE (((Format([SumOfNet Amount]-[Accrual Amount],"Currency"))>0));
to this:
Code:
WHERE ([SumOfNet Amount]-[Accrual Amount])>0;
FWIW, I would recommend changing the format of the field in your Query/Form/Report instead of trying to do it right in the calculated field anyway.
 
Upvote 0
Thanks. Yes, I am going to just the change to the saved import steps, since I have to deal with this on a regular basis.
 
Upvote 0

Forum statistics

Threads
1,216,143
Messages
6,129,110
Members
449,486
Latest member
malcolmlyle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top