Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transpose data best practice
Message
From
24/08/2002 12:40:42
 
 
To
24/08/2002 06:28:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00693069
Message ID:
00693298
Views:
31
Cetin,

What does 0x00000000 do? I ran into an error in this line. However, I got the idea. I think I can make changes to the code to implement our requirements.

Thanks

>>Hi all,
>>
>>Is there a best practice to transpose data in VFP based on a column or columns
>>
>>
>>Example: Transpose data by F4, then F1
>>Table1
>>F1   F2   F3  F4
>>AAA   1    1  8/22/02
>>AAA   2    1  8/22/02
>>AAA   3    1  8/22/02
>>BBB   1    1  8/22/02
>>BBB   2    1  8/23/02
>>CCC   3    1  8/23/02
>>
>>Result:
>>
>>F4       F2 F3AAA F3BBB F3CCC
>>8/22/02   1     1     1     -
>>8/22/02   2     1     1     -
>>8/22/02   3     1     -     -
>>8/23/02   2     -     1     -
>>8/23/02   3     -     -     1
>>
>
>
>Ramil,
>There vfpxtab.prg (_genxtab). However depending on your needs it might be much more effective to create your own version. Your data sounds like one that vfpxtab wouldn't handle. ie (assuming your result set have a typo for 'BBB' series :
>
>
select distinct f1 from myTable into array arrExtraCols
>IF _Tally = 0
>	MESSAGEBOX('No rows to process')
>	RETURN
>endif
>&& Assuming 'F3'+F1 values qualify to be a fieldname
>lcExtra = ''
>for ix=1 to alen(arrExtraCols,1)
>  lcExtra = lcExtra + ',0x00000000 as F3'+trim(arrExtraCols[ix,1])
>endfor
>select distinct f4,f2 &lcExtra from myTable into cursor xTabbed readwrite
>scan
> scatter name oRecord
> select myTable
> for ix=3 to fcount('xTabbed')
>   locate for f4 = oRecord.f4 and f2 = oRecord.f2 and ;
>       upper(f1) = substr(field(ix,'xTabbed'),3)
>   store f3 to ('oRecord.'+field(ix,'xTabbed'))
> endfor
> select xTabbed
> gather name oRecord
>ENDSCAN
>browse
Cetin
ramil
~~ learning to stand still
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform