formats and imports

jmoe007

New Member
Joined
Mar 16, 2011
Messages
4
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Hello All. <o:p></o:p>
having some issues with my statment and/or import.<o:p></o:p>
<o:p> </o:p>
Using a statment to count the number of rows by type and then format the count of rows into a number.<o:p></o:p>
Issue Im having is when i load my sql statment into excel and run my query, the count of row column comes down as a text, which i have to format into number to be able to pivot table the data. but when i refresh my query, the row count column reverts back to a text (general) format and lose the ability to use my pivot table.<o:p></o:p>
<o:p> </o:p>
End result is to have my pivot table update when refreshed using my statement below<o:p></o:p>
<o:p> </o:p>
is there a way to code my sql statment so the row count is allready cast as interger when i run my query in excel or is there a way in excel to keep the column format as number.<o:p></o:p>
<o:p> </o:p>
SELECT <o:p></o:p>
<o:p> </o:p>
A.AsofDate,<o:p></o:p>
datename(weekday,DATEPART(weekday,AsofDate))as Weekday,<o:p></o:p>
A.NAME as List,<o:p></o:p>
cast(COUNT(NAME) as int)AS Listcount<o:p></o:p>
<o:p> </o:p>
FROM <o:p></o:p>
[x].[dbo].[x] as A<o:p></o:p>
<o:p> </o:p>
Where <o:p></o:p>
AsofDate>=DateAdd(day, DateDiff(day,0,getdate()),-30)<o:p></o:p>
<o:p> </o:p>
group by <o:p></o:p>
A.AsofDate,A.NAME<o:p></o:p>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Count does return a number. There is no need to cast it to int.

I would rebuild the pivot table in a clean sheet (safest). You probably got a text value in there once by mistake and now its "stuck" that way. Or for a quick fix, you could *try* removing all data from the pivot table and refreshing the empty pivot table. Then put the items back in and see if the numeric values stay. Be sure the sheet is not using text format in any cells. Check the number format of the pivot table columns to make sure they aren't in text format either.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,726
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