Local lcFieldName, lnLen, liFld, laYears[ 1 ], lcVarName, lcCurKey, liYear, lnAmt, liNdx, lcYear *** For this method to work, it assumes that the cursor coming in has the *** month identifier in the first column, the number we want to aggregate *** is in the second column and the year indentifier is in the third column. *** get the field from the results cursor that we are grouping by lcFieldName = Field( 1, 'csrResults' ) lnLen = Len( Evaluate( 'csrResults.' + lcFieldName ) ) *** Save csrResults Select * From csrResults Into Cursor csrSave NOFILTER Use In csrResults Create Cursor csrResults ( &lcFieldName C( lnLen ) ) *** Find out how many distinct years there are Select Distinct nYear From csrSave Order By nYear Into Array laYears *** Now add the columns for whatever years we have *** Store the field names in some variables For liFld = 1 To Alen( laYears, 1 ) lcVarName = 'Year' + Transform( laYears[ liFld ] ) Alter Table csrResults Add Column &lcVarName N( 14, 2 ) Endfor *** Now scan through the original cursor *** and make the results "horizontal" for all years Select csrSave lcCurKey = "" Scan If Not( Alltrim( Evaluate( 'csrSave.' + lcFieldName ) ) == lcCurKey ) *** Time to insert a new record lcCurKey = Alltrim( Evaluate( 'csrSave.' + lcFieldName ) ) Insert Into csrResults( &lcFieldName ) Values ( lcCurKey ) Endif lcYear = 'Year' + Transform( Evaluate( Field( 3, 'csrSave' ) ) ) lnAmt = Evaluate( Field( 2, 'csrSave' ) ) Replace ( lcYear ) With lnAmt In csrResults Endscan