Convert Text to Number in MS Query

Nighabi

New Member
Joined
Feb 13, 2008
Messages
34
I have a pivot table that I run against a saved query. The problem is one of the numbers I want to add is s String in the data source so I need to convert it to value.
I tried to use CDBL in the SQL editor of MS Query but when I format it as below
Select CDBL(DataSource.TransQty),
DataSource.Product
From DataSource
I get an error
Lexical element not found: FROM
Not sure what I am doing wrong.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Just a thought...

Could you import the number as a string and multiply it by 1 in excel to make it a number?
 
Upvote 0
Problem with that is I'm trying to bring the data directly into a pivot table to avoid having to refresh the data and then refreshing the pivot table.
 
Upvote 0
That doesn't work because one of the fields isn't a number. I guess pivot tables work differently than when you just retrieve the data. When I dump the data to a table, I can do math on the field and it works, if I bring it directly into a pivot table, I can't do math because it contains strings.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

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