Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cross Tab Query
Message
From
15/09/1998 11:18:35
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Miscellaneous
Thread ID:
00136735
Message ID:
00136768
Views:
22
>>Hi,
>>
>>I am new to this forum and also to Visual FoxPro. I am trying to figure out how to run a query and output the information to a table or a report. This is what I need to do:
>>
>>Product Jan Feb Mar Apr May etc.
>>q1 12 0 3 8 12
>>w9 9 5 12 13 15
>>etc.
>>
>>Basically, I want to run a query that will tell me that I have sold X amount of product 1 in Jan, Feb, etc and continue to do that for all products. I am having trouble using the cross-tab query wizard. I cannot get the query to total the products by month. Any information you can provide will be greatly appreciated.
>>
>>Thank you,
>>
>>Jim Catanich
>
>Jim,
>
>I can help you get your totals. After your xtab query, try this:
>
> FOR lnCnt = 2 TO FCOUNT()
> lcFieldName = 'MyField.'+FIELD(lnCnt)
> CALCULATE SUM(&lcFieldName) TO lnSum
> GO BOTTOM
> REPLACE &lcFieldName WITH lnSum
> ENDFOR
>
>Worked like a charm for me!!
>
>HTH
Peryy,
Nice ! This would work but just before this routine do not forget to append one blank record.
Here is another approach which I find fast :
lparameters cXtabTableName
sum to array aSums             && Sum to array - fcount()-1 elems
dimension aSums[alen(aSums)+1] && Dimension array fcount()
ains(aSums,1)                  && Insert a new element at top
aSums[1]="Totals"              && So last rec displays "totals"
insert into (cXtabTableName) ;
  from array aSums             && Add totals rec into xtab
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform