function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert SpearRobert Spear 

Cogroup in Einstein Analytics

Hi everybody, I'm trying to split an Einstein Analytics dataset into different date groups, and then append the columns to one another.I'd like to assign a certain date range to one variable, the previous week to a second variable, and then cogroup the two by day number. I've attached a sample of what I'm able to achieve with a "union" function, however my goal would be to join the "Data_Re.Day_Week_Num" columns to bring this information on the same line. 
User-added image
Here's my attempt at using a cogroup to join the two, however I get an ID TOKEN error in my last "foreach" when trying to refer to either column in q2 or q3.
q= 'DateSource;
q2 = filter q by date('Disposition_Time__c_Year', 'Disposition_Time__c_Month', 'Disposition_Time__c_Day') in [dateRange([2017,12,05], [2018,12,05])];
q2 = filter q2 by 'Data_Re.Week_Num' in ["48"];
q2 = filter q2 by 'Data_Re.Day_Week_Num' in ["1","2","3","4","5"];
q2 = group q2 by ('Disposition_Time__c_Year', 'Disposition_Time__c_Month', 'Disposition_Time__c_Day','Data_Re.Week_Num','Data_Re.Day_Week_Num','Disposition_Date__c','Data_Re.Previous_Week_Num');
q3 = filter q by date('Disposition_Time__c_Year', 'Disposition_Time__c_Month', 'Disposition_Time__c_Day') in [dateRange([2017,12,05], [2018,12,05])];
q3 = filter q3 by 'Data_Re.Week_Num' == "47";
q3 = filter q3 by 'Data_Re.Day_Week_Num' in ["1","2","3","4","5"];
q3 = filter q3 by 'Disposition_Time__c_Year' != "2017";
q3 = group q3 by ('Disposition_Time__c_Year', 'Disposition_Time__c_Month', 'Disposition_Time__c_Day','Data_Re.Week_Num','Data_Re.Day_Week_Num', 'Data_Re.Previous_Week_Num','Disposition_Date__c');
q3 = foreach q3 generate  'Data_Re.Day_Week_Num' as 'Data_Re.Day_Week_Num', 'Data_Re.Previous_Week_Num' as 'Data_Re.Previous_Week_Num', 'Disposition_Date__c' as 'Disposition_Date__c';
q2 = foreach q2 generate 'Data_Re.Day_Week_Num' as 'Data_Re.Day_Week_Num', 'Data_Re.Previous_Week_Num' as 'Data_Re.Previous_Week_Num', 'Disposition_Date__c' as 'Disposition_Date__c';
qtot= cogroup q2 by ('Data_Re.Day_Week_Num'),q3 by ('Data_Re.Day_Week_Num');
qtot= foreach qtot generate q3.'Data_Re.Day_Week_Num' as 'Data_Re.Day_Week_Num', q2.'Disposition_Date__c' as 'Disposition_Date__c2', q3.'Disposition_Date__c' as 'Disposition_Date__c3';

Has anyone done something similar? Thanks for any help you can provide!
Best Answer chosen by Robert Spear
Robert SpearRobert Spear
Solved: only include the 'foreach' after the cogroup, or else it won't recognize the column names you're referring to :)