Wed Mar 21, 2018 4:40 pm
Login Register Lost Password? Contact Us

Getting Error: Output( ) appears to be conext dependent

Questions around writing code and queries

Mon Jun 05, 2017 6:36 pm Change Time Zone

Hi There!

I keep getting this error when I am trying to look at a dataset I'm creating..

Error: OUTPUT() appears to be context dependent - this may cause a dataset not active error (445, 1), 4533,

Can someone help me not get this error? I can run it without the last output but I cannot run when I try to output my dataset after my rollup.
Code: Select all
g_JoiningAllCalendarDates := group(JoiningAllCalendarDates, telematicsid,int_date);

// this section is to roll up on the driver level by telematicsid and reportdate descending

StandardReportScoresRec := RECORD

// roll up transform
StandardReportScoresRec ReportDateRollUp(StandardReportScoresRec Le, StandardReportScoresRec Ri) := TRANSFORM
   SELF.totaldistance:= Le.totaldistance+Ri.totaldistance;
   SELF.totalhardbrakes:= LE.totalhardbrakes+RI.totalhardbrakes;
   SELF.totalhardbrakes_secbysecacc:= LE.totalhardbrakes_secbysecacc+RI.totalhardbrakes_secbysecacc;
   SELF.weekdaynightdrvmiles:= LE.weekdaynightdrvmiles+RI.weekdaynightdrvmiles;
   SELF.weekendnightdrvmiles:= LE.weekendnightdrvmiles+RI.weekendnightdrvmiles;
   SELF.weekdayeveningdrvmiles:= LE.weekdayeveningdrvmiles+RI.weekdayeveningdrvmiles;
   SELF.weekendeveningdrvmiles:= LE.weekendeveningdrvmiles+RI.weekendeveningdrvmiles;
   SELF.saturdaymorningdrvmiles:= LE.saturdaymorningdrvmiles+RI.saturdaymorningdrvmiles;
   SELF.sundaymorningdrvmiles:= LE.sundaymorningdrvmiles+RI.sundaymorningdrvmiles;
   SELF.hwy15spdingmiles:= LE.hwy15spdingmiles+RI.hwy15spdingmiles;
   SELF.hwyspdoppmiles:= LE.hwyspdoppmiles+RI.hwyspdoppmiles;
   SELF.lcl10spdingmiles:= LE.lcl10spdingmiles+RI.lcl10spdingmiles;
   SELF.lclspdoppmiles:= LE.lclspdoppmiles+RI.lclspdoppmiles;
   SELF.totalturndegrees:= LE.totalturndegrees+RI.totalturndegrees;
   SELF.tripcnts:= LE.tripcnts+RI.tripcnts;
   SELF := LE;

StandardReportScores00 := ROLLUP(g_JoiningAllCalendarDates,GROUP, ReportDateRollUp(LEFT,RIGHT));


Posts: 25
Joined: Mon Jun 02, 2014 3:16 pm

Mon Jun 05, 2017 7:25 pm Change Time Zone


Your problem here is that you're using the GROUP form of ROLLUP (form 3) but your TRANSFORM function is written for the non-GROUP forms (forms 1 & 2). As the ROLLUP docs state:
For form 3 of ROLLUP, the transform function must take at least two parameters: a LEFT record which must be in the same format as the recordset, and a ROWS(LEFT) whose format must be a DATASET(RECORDOF(recordset)) parameter. The format of the resulting record set may be different from the inputs.
Here's a simple example showing the difference (both ROLLUP forms shown in this example produce the same result):
Code: Select all
   STRING1 Value1;
   STRING1 Value2;
   UNSIGNED1 Value3;

SomeFile := DATASET([{'C','G',1},

SortedTable := SORT(SomeFile,Value1);

//The "usual" form of ROLLUP (form 1):
MyRec RollThem(MyRec L, MyRec R) := TRANSFORM
  SELF.Value2 := MIN(L.Value2,R.Value2);
  SELF.Value3 := MIN(L.Value3,R.Value3);
  SELF := L;

RolledUpRecs := ROLLUP(SortedTable,
                       LEFT.Value1 = RIGHT.Value1,

OUTPUT(RolledUpRecs );

//GROUP form of ROLLUP (form 3):
Grecs := GROUP(SortedTable,Value1);   //note this uses the SORTed recordset

MyRec RollThem2(MyRec L, DATASET(MyRec) R) := TRANSFORM
  SELF.Value1 := L.Value1;
  SELF.Value2 := MIN(R,R.Value2);
  SELF.Value3 := MIN(R,R.Value3);

Note the second parameter to the second TRANSFORM is different, and that the MIN functions are also using a different form in the second TRANSFORM.


Community Advisory Board Member
Community Advisory Board Member
Posts: 1341
Joined: Wed Oct 26, 2011 7:40 pm

Mon Jun 05, 2017 7:43 pm Change Time Zone

Thank you so much for explaining Richard!
Posts: 25
Joined: Mon Jun 02, 2014 3:16 pm

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest