• sri__p
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I tried several ways but keep getting below error on Challenge 1. Any help or guidance is greatly appreciated.

https://trailhead.salesforce.com/en/content/learn/superbadges/superbadge_analytics_insights_specialist

Challenge Not yet complete... here's what's wrong:
We can't confirm this is the correct quarter. Records should be grouped by subscriber activity (sign ups and cancellations). A suggestion is to generate a stream for subscriber records by Subscription Date and its counts, along with Churn Date and its counts. Ensure both streams for these date fields share a common variable then create a union of both streams.

 
q = load "Beattie_Subs";

subs = group q by ('Subscription_Date_Year', 'Subscription_Date_Quarter');
subs = foreach subs generate 'Subscription_Date_Year' + "-" + 'Subscription_Date_Quarter' as 'ActivityDate_Year-ActivityDate_Quarter', count() as 'Current Quarter Subscribers';

churns = group q by ('Churn_Date_Year', 'Churn_Date_Quarter');
churns = foreach churns generate 'Churn_Date_Year' + "-" + 'Churn_Date_Quarter' as 'ActivityDate_Year-ActivityDate_Quarter', count() as 'Current Quarter Churns';

result = group subs by 'ActivityDate_Year-ActivityDate_Quarter' full, churns by 'ActivityDate_Year-ActivityDate_Quarter';
result = foreach result generate coalesce(subs.'ActivityDate_Year-ActivityDate_Quarter', churns.'ActivityDate_Year-ActivityDate_Quarter') as 'ActivityDate_Year-ActivityDate_Quarter', sum(subs.'Current Quarter Subscribers') as 'Current Quarter Subscribers', sum(churns.'Current Quarter Churns') as 'Current Quarter Churns';
result = group result by ('ActivityDate_Year-ActivityDate_Quarter', 'Current Quarter Subscribers', 'Current Quarter Churns');
result = foreach result generate 'ActivityDate_Year-ActivityDate_Quarter', sum('Current Quarter Subscribers') as 'Current Quarter Subscribers', 'Current Quarter Churns', sum('Current Quarter Subscribers') over ([..-1] partition by all order by 'ActivityDate_Year-ActivityDate_Quarter') - coalesce(sum('Current Quarter Churns') over ([-1..-1] partition by all order by 'ActivityDate_Year-ActivityDate_Quarter'),0) as 'Previous Quarter Subscribers';
result = foreach result generate 'ActivityDate_Year-ActivityDate_Quarter', 'Current Quarter Churns'/(coalesce('Previous Quarter Subscribers',0) + coalesce('Current Quarter Subscribers',0)) as 'Churn Rate';

Thanks
Sri.​​​​​​​
  • April 03, 2020
  • Like
  • 0